Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/store.zig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub const Store = struct {

const entry = try self.files.getOrPut(path);
if (!entry.found_existing) {
errdefer self.files.removeByPtr(entry.key_ptr);
const duped = try self.allocator.dupe(u8, path);
entry.key_ptr.* = duped;
entry.value_ptr.* = FileVersions.init(self.allocator, duped);
Expand Down
10 changes: 10 additions & 0 deletions src/test_core.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1172,3 +1172,13 @@ test "issue-597: data log compacts orphaned diff ranges and fixes offsets" {
_ = try log_file.readPositionalAll(io, &buf, 5);
try testing.expectEqualStrings("DDDDD", &buf);
}


test "issue-603: appendVersion failed key dupe leaves a poisoned files entry" {
var failing = std.testing.FailingAllocator.init(testing.allocator, .{ .fail_index = 1 });
var store = Store.init(failing.allocator());

try testing.expectError(error.OutOfMemory, store.recordSnapshot("src/a.zig", 10, 0x1));
try testing.expectEqual(@as(usize, 0), store.files.count());
store.deinit();
}
Loading