mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:44:43 +01: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
2 changed files with 7 additions and 3 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue