From 4c9e238c3f32bc3ba49afd484bfcde48f2a84f94 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Fri, 29 Mar 2024 13:15:24 -0400 Subject: [PATCH] fix(termio/exec): avoid overflow in setCursorRow/ColRelative Using a saturating addition here just to avoid overflow, since setCursorPos handles proper clamping to the screen size so we don't need to duplicate that logic. --- src/termio/Exec.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 43708ed2b..27ac5a078 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1993,7 +1993,7 @@ const StreamHandler = struct { pub fn setCursorColRelative(self: *StreamHandler, offset: u16) !void { self.terminal.setCursorPos( self.terminal.screen.cursor.y + 1, - self.terminal.screen.cursor.x + 1 + offset, + self.terminal.screen.cursor.x + 1 +| offset, ); } @@ -2003,7 +2003,7 @@ const StreamHandler = struct { pub fn setCursorRowRelative(self: *StreamHandler, offset: u16) !void { self.terminal.setCursorPos( - self.terminal.screen.cursor.y + 1 + offset, + self.terminal.screen.cursor.y + 1 +| offset, self.terminal.screen.cursor.x + 1, ); }