Skip to content

Commit f780a6b

Browse files
xEgoistandrewrk
authored andcommitted
std: further windows resource fix
addition to #15450 createFileW does not account for failure on `LockFile`. This can result in a file handle not being closed on failure which can be seen on test such as `fs.test.'open file with exclusive nonblocking lock twice'`.
1 parent d8bdfd8 commit f780a6b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/std/fs.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ pub const Dir = struct {
13971397
.capable_io_mode = std.io.default_mode,
13981398
.intended_io_mode = flags.intended_io_mode,
13991399
};
1400+
errdefer file.close();
14001401
var io: w.IO_STATUS_BLOCK = undefined;
14011402
const range_off: w.LARGE_INTEGER = 0;
14021403
const range_len: w.LARGE_INTEGER = 1;

0 commit comments

Comments
 (0)