Commit 5cc6265
committed
Fix nil pointer panic in commonLock defer
The defer function in commonLock calls file.Close() when an error
occurs, but file is always nil at that point. If os.Open or
os.OpenFile fails, file is nil. If platformSpecificLock fails, file
is closed inline and then set to nil by the return statement. In
both cases, calling file.Close() in the defer panics on a nil
pointer. Add nil check before file.Close() in the defer.
Signed-off-by: Federico Bramucci <163430291+fedebram@users.noreply.github.com>1 parent 0951079 commit 5cc6265
1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
0 commit comments