diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index 154dfee22..186b99608 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -373,6 +373,9 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action { break :param null; } + // Ignore parameters that are too long + if (self.param_acc_idx == std.math.maxInt(u8)) break :param null; + // A numeric value. Add it to our accumulator. if (self.param_acc_idx > 0) { self.param_acc *|= 10; @@ -388,6 +391,9 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action { break :osc_put null; }, .csi_dispatch => csi_dispatch: { + // Ignore too many parameters + if (self.params_idx >= MAX_PARAMS) break :csi_dispatch null; + // Finalize parameters if we have one if (self.param_acc_idx > 0) { self.params[self.params_idx] = self.param_acc; diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 823f9ff67..fe5a72f2f 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -284,7 +284,7 @@ pub const Parser = struct { .@"0" => switch (c) { ';' => { - self.command = .{ .change_window_title = undefined }; + self.command = .{ .change_window_title = &.{} }; self.state = .string; self.temp_state = .{ .str = &self.command.change_window_title }; @@ -328,7 +328,7 @@ pub const Parser = struct { .@"2" => switch (c) { '2' => self.state = .@"22", ';' => { - self.command = .{ .change_window_title = undefined }; + self.command = .{ .change_window_title = &.{} }; self.state = .string; self.temp_state = .{ .str = &self.command.change_window_title }; @@ -339,7 +339,7 @@ pub const Parser = struct { .@"22" => switch (c) { ';' => { - self.command = .{ .mouse_shape = undefined }; + self.command = .{ .mouse_shape = .{ .value = &.{} } }; self.state = .string; self.temp_state = .{ .str = &self.command.mouse_shape.value }; @@ -366,7 +366,7 @@ pub const Parser = struct { .@"52" => switch (c) { ';' => { - self.command = .{ .clipboard_contents = undefined }; + self.command = .{ .clipboard_contents = .{ .kind = undefined, .data = &.{} } }; self.state = .clipboard_kind; }, else => self.state = .invalid,