diff options
Diffstat (limited to 'core/fs.zig')
| -rw-r--r-- | core/fs.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/fs.zig b/core/fs.zig index 6b43ba67..f428212b 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -1026,7 +1026,9 @@ pub const Namespace = struct { st.mounts.deinit(gpa); for (st.os_paths.items) |entry| gpa.free(entry.path); st.os_paths.deinit(gpa); - for (st.opens[0..st.opens_len]) |*o| o.deinit(gpa); + // A dump refused for its `opens_len` (walk.holdTo) left it saying + // more than it holds when the load's errdefer tears this down. + for (st.opens[0..@min(st.opens_len, st.opens.len)]) |*o| o.deinit(gpa); for (st.pages.items) |*page| page.bytes.deinit(gpa); st.pages.deinit(gpa); for (st.closed_lines.items) |*line| line.bytes.deinit(gpa); @@ -1594,3 +1596,9 @@ test "a write open(2) refuses says its errno in words" { var words: [128]u8 = undefined; try std.testing.expectEqualStrings("no such file or directory", pardes.Messages.errorWords(error.NoSuchFileOrDirectory, &words)); } + +test "a namespace a refused dump left saying more opens than it holds is torn down to its last" { + var st: Namespace = .{}; + st.opens_len = st.opens.len + 34; + st.deinit(std.testing.allocator); +} |
