commit f780a6b024f25838560cce6e0bd93c808e09457b (tree)
parent d8bdfd8192fb43ca8f6abd223396a4073e369499
Author: xEgoist <egoist@egoistic.dev>
Date: Tue, 25 Apr 2023 11:21:52 -0500
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'`.
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
@@ -1397,6 +1397,7 @@ pub const Dir = struct {
.capable_io_mode = std.io.default_mode,
.intended_io_mode = flags.intended_io_mode,
};
+ errdefer file.close();
var io: w.IO_STATUS_BLOCK = undefined;
const range_off: w.LARGE_INTEGER = 0;
const range_len: w.LARGE_INTEGER = 1;