Skip to content

Commit

Permalink
envknob: ensure f is not nil before using it
Browse files Browse the repository at this point in the history
This PR fixes a panic that I saw in the mac app where
parsing the env file fails but we don't get to see the
error due to the panic of using f.Name()

Fixes tailscale#11425

Signed-off-by: Marwan Sulaiman <marwan@tailscale.com>
  • Loading branch information
marwan-at-work committed Mar 15, 2024
1 parent 08ebac9 commit da7c3d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion envknob/envknob.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,11 @@ func ApplyDiskConfig() (err error) {
defer func() {
if err != nil {
// Stash away our return error for the healthcheck package to use.
applyDiskConfigErr = fmt.Errorf("error parsing %s: %w", f.Name(), err)
if f != nil {
applyDiskConfigErr = fmt.Errorf("error parsing %s: %w", f.Name(), err)
} else {
applyDiskConfigErr = fmt.Errorf("error applying disk config: %w", err)
}
}
}()

Expand Down

0 comments on commit da7c3d1

Please sign in to comment.