From f780a6b024f25838560cce6e0bd93c808e09457b Mon Sep 17 00:00:00 2001 From: xEgoist Date: Tue, 25 Apr 2023 11:21:52 -0500 Subject: [PATCH] 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'`. --- lib/std/fs.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 8ea2cf91c1..290eb151f7 100644 --- 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;