mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:44:43 +01:00
std.Io.Threaded: fix resource leak in dirRealPathFilePosix
it should unconditionally close the opened file descriptor, not only on error.
This commit is contained in:
parent
eb0d5b1377
commit
0dbcf97551
1 changed files with 8 additions and 7 deletions
|
|
@ -4165,7 +4165,7 @@ fn dirRealPathFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, o
|
|||
},
|
||||
}
|
||||
};
|
||||
errdefer posix.close(fd);
|
||||
defer posix.close(fd);
|
||||
return realPathPosix(current_thread, fd, out_buffer);
|
||||
}
|
||||
|
||||
|
|
@ -4290,16 +4290,17 @@ fn realPathPosix(current_thread: *Thread, fd: posix.fd_t, out_buffer: []u8) File
|
|||
try current_thread.checkCancel();
|
||||
continue;
|
||||
},
|
||||
else => |e| {
|
||||
.BADF => {
|
||||
current_thread.endSyscall();
|
||||
switch (e) {
|
||||
.BADF => return error.FileNotFound,
|
||||
else => |err| return posix.unexpectedErrno(err),
|
||||
}
|
||||
return error.FileNotFound;
|
||||
},
|
||||
else => |err| {
|
||||
current_thread.endSyscall();
|
||||
return posix.unexpectedErrno(err);
|
||||
},
|
||||
}
|
||||
}
|
||||
const len = std.mem.indexOfScalar(u8, &k_file.path, 0) orelse k_file.path.len;
|
||||
const len = std.mem.findScalar(u8, &k_file.path, 0) orelse k_file.path.len;
|
||||
if (len == 0) return error.NameTooLong;
|
||||
return len;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue