authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-06-04 18:44:07-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-06-04 18:45:25-07:00
log5490021ab7d97425a44b78e218b5462f960d9c9d
treebdbf16fdd0658573db8f1871b8a86f0b6445c166
parent332fbb4b027a5529e58b1e46d785718a7faa75e6

Dir.makeOpenPathAccessMaskW: Fix leaking intermediate directory handles

Fixes a regression introduced in 67455c5e70e86dbb7805ff9a415f1b13b14f36da. The `errdefer` cannot run since its not possible for an error to occur, and we don't want it to run on the last handle, so we move the closing back down to where it was before 67455c5e70e86dbb7805ff9a415f1b13b14f36da.

1 files changed, 5 insertions(+), 2 deletions(-)

lib/std/fs/Dir.zig+5-2
......@@ -1217,10 +1217,13 @@ fn makeOpenPathAccessMaskW(self: Dir, sub_path: []const u8, access_mask: u32, no
12171217 },
12181218 else => |e| return e,
12191219 };
1220 // Don't leak the intermediate file handles
1221 errdefer if (result) |*dir| dir.close();
12221220
12231221 component = it.next() orelse return result.?;
1222
1223 // Don't leak the intermediate file handles
1224 if (result) |*dir| {
1225 dir.close();
1226 }
12241227 }
12251228}
12261229