Skip to content

Commit

Permalink
cilium-dbg: don't write to file on error opening
Browse files Browse the repository at this point in the history
If os.OpenFile returns an error we shouldn't be writing to the returned
os.(*File) instance which might be nil.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
  • Loading branch information
tklauser committed Apr 3, 2024
1 parent 9c07c4b commit 09572e2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cilium-dbg/cmd/debuginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ func writeMarkdown(data []byte, path string) {
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not create file %s", path)
os.Exit(1)
}
w := tabwriter.NewWriter(f, 5, 0, 3, ' ', 0)
w.Write(data)
Expand Down

0 comments on commit 09572e2

Please sign in to comment.