mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Merge pull request #20192 from squeek502/fs-handle-leaks
Fix handle leaks in `Dir.makeOpenPathAccessMaskW` and a `fs` test
This commit is contained in:
commit
8c04ffba86
@ -1217,10 +1217,13 @@ fn makeOpenPathAccessMaskW(self: Dir, sub_path: []const u8, access_mask: u32, no
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
// Don't leak the intermediate file handles
|
||||
errdefer if (result) |*dir| dir.close();
|
||||
|
||||
component = it.next() orelse return result.?;
|
||||
|
||||
// Don't leak the intermediate file handles
|
||||
if (result) |*dir| {
|
||||
dir.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1161,7 +1161,8 @@ test "makepath existing directories" {
|
||||
defer tmp.cleanup();
|
||||
|
||||
try tmp.dir.makeDir("A");
|
||||
const tmpA = try tmp.dir.openDir("A", .{});
|
||||
var tmpA = try tmp.dir.openDir("A", .{});
|
||||
defer tmpA.close();
|
||||
try tmpA.makeDir("B");
|
||||
|
||||
const testPath = "A" ++ fs.path.sep_str ++ "B" ++ fs.path.sep_str ++ "C";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user