std: Close dangling fd on error

This patch was already submitted for openFileZ, createFileZ was left
unpatched.
This commit is contained in:
LemonBoy 2020-11-23 09:11:03 +01:00
parent 0d4f05bb8a
commit 26d20e39fc

View File

@ -892,6 +892,7 @@ pub const Dir = struct {
try std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, os_flags, flags.mode)
else
try os.openatZ(self.fd, sub_path_c, os_flags, flags.mode);
errdefer os.close(fd);
if (!has_flock_open_flags and flags.lock != .None) {
// TODO: integrate async I/O