mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-05 07:08:39 +00:00
core: free allocated writes in read-only mode (#13574)
Read-only filtering happens in Surface.queueIo after callers construct the message. This early return leaked write_alloc payloads because the IO thread never receives them and therefore does not perform its normal cleanup.
This commit is contained in:
@@ -872,9 +872,13 @@ fn queueIo(
|
||||
switch (msg) {
|
||||
.write_small,
|
||||
.write_stable,
|
||||
.write_alloc,
|
||||
=> return,
|
||||
|
||||
.write_alloc => |v| {
|
||||
v.alloc.free(v.data);
|
||||
return;
|
||||
},
|
||||
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
@@ -6064,3 +6068,18 @@ fn presentSurface(self: *Surface) !void {
|
||||
pub fn getProcessInfo(self: *Surface, comptime info: ProcessInfo) ?ProcessInfo.Type(info) {
|
||||
return self.io.getProcessInfo(info);
|
||||
}
|
||||
|
||||
test "queueIo frees allocated writes in readonly mode" {
|
||||
const testing = std.testing;
|
||||
|
||||
const surface = try testing.allocator.create(Surface);
|
||||
defer testing.allocator.destroy(surface);
|
||||
surface.readonly = true;
|
||||
|
||||
// queueIo must free allocated writes in read-only mode.
|
||||
const data = try testing.allocator.dupe(u8, "\x1b]lGhostty\x1b\\");
|
||||
surface.queueIo(.{ .write_alloc = .{
|
||||
.alloc = testing.allocator,
|
||||
.data = data,
|
||||
} }, .unlocked);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user