Commit f780a6b024

xEgoist <egoist@egoistic.dev>
2023-04-25 18:21:52
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
Changed files (1)
lib
std
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;