Commit d8bdfd8192

Jacob Young <jacobly0@users.noreply.github.com>
2023-04-25 01:47:05
std: fix windows resource leaks
1 parent a2fe81a
Changed files (2)
lib
lib/std/os/test.zig
@@ -1101,6 +1101,8 @@ test "isatty" {
     defer tmp.cleanup();
 
     var file = try tmp.dir.createFile("foo", .{});
+    defer file.close();
+
     try expectEqual(os.isatty(file.handle), false);
 }
 
lib/std/fs.zig
@@ -1236,6 +1236,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;