fix(lib): add saturating subtraction to prevent integer underflow

This commit is contained in:
Amaan Qureshi 2024-12-25 03:06:38 -05:00
parent 7ba0f297e5
commit f3d50f273b
3 changed files with 74 additions and 4 deletions

View file

@ -22,7 +22,7 @@ static inline TSPoint point_sub(TSPoint a, TSPoint b) {
if (a.row > b.row)
return point__new(a.row - b.row, a.column);
else
return point__new(0, a.column - b.column);
return point__new(0, (a.column >= b.column) ? a.column - b.column : 0);
}
static inline bool point_lte(TSPoint a, TSPoint b) {