authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-17 18:26:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-19 12:39:37-07:00
loge820cf38ed05702aa08c3b61bd0bc5cdc4bc74b0
tree1e79a24a5ef68a95096d8a699e4a02a61dbe8cbf
parente8090258b5ca045d7b89fdf625115477514880e0

std.zig.Directories: fix deinit of build_root


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

lib/std/zig.zig+2-2
......@@ -1291,11 +1291,12 @@ pub const Directories = struct {
12911291 pub fn deinit(dirs: *Directories, io: Io) void {
12921292 // The local and global caches could be the same.
12931293 const close_local = dirs.local_cache.handle.handle != dirs.global_cache.handle.handle;
1294 const close_build_root = dirs.build_root.handle.handle != Io.Dir.cwd().handle;
12941295
12951296 dirs.global_cache.handle.close(io);
12961297 if (close_local) dirs.local_cache.handle.close(io);
12971298 dirs.zig_lib.handle.close(io);
1298 if (dirs.build_root.path != null) dirs.build_root.handle.close(io);
1299 if (close_build_root) dirs.build_root.handle.close(io);
12991300 }
13001301
13011302 /// Returns a `Directories` where `local_cache` is replaced with `global_cache`, intended for
......@@ -1346,7 +1347,6 @@ pub const Directories = struct {
13461347 };
13471348 };
13481349 const build_root: Cache.Directory = if (options.build_root) |s|
1349 // TODO this ends up setting path to null, leaking the fd in deinit
13501350 openUnresolved(arena, io, cwd, s, .@"build root")
13511351 else
13521352 .cwd();