fix: crash in Buffer.set_file_path

This commit is contained in:
CJ van den Berg 2025-08-06 19:45:28 +02:00
parent c88e2dd975
commit 1babf86ce4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -1100,6 +1100,7 @@ pub fn get_meta(self: *Self) ?[]const u8 {
}
pub fn set_file_path(self: *Self, file_path: []const u8) void {
if (file_path.ptr == self.file_path_buf.items.ptr) return;
self.file_path_buf.clearRetainingCapacity();
self.file_path_buf.appendSlice(self.external_allocator, file_path) catch |e| switch (e) {
error.OutOfMemory => @panic("OOM in Buffer.set_file_path"),