terminal: fix uninitialized memory access when kitty color protocol

This commit is contained in:
Mitchell Hashimoto
2024-09-06 14:08:16 -07:00
parent c16a4fd95e
commit f4052fd824

View File

@ -493,6 +493,7 @@ pub const Parser = struct {
}, },
}; };
self.temp_state = .{ .key = "" };
self.state = .kitty_color_protocol_key; self.state = .kitty_color_protocol_key;
self.complete = true; self.complete = true;
self.buf_start = self.buf_idx; self.buf_start = self.buf_idx;
@ -1730,3 +1731,17 @@ test "OSC: kitty color protocol double reset" {
p.reset(); p.reset();
p.reset(); p.reset();
} }
test "OSC: kitty color protocol no key" {
const testing = std.testing;
var p: Parser = .{ .alloc = testing.allocator };
defer p.deinit();
const input = "21;";
for (input) |ch| p.next(ch);
const cmd = p.end('\x1b').?;
try testing.expect(cmd == .kitty_color_protocol);
try testing.expectEqual(0, cmd.kitty_color_protocol.list.items.len);
}