std: fix windows resource leaks

This commit is contained in:
Jacob Young 2023-04-24 19:47:05 -04:00 committed by Andrew Kelley
parent a2fe81a639
commit d8bdfd8192
2 changed files with 3 additions and 0 deletions

View File

@ -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;

View File

@ -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);
}