fix(lib): add saturating subtraction to prevent integer underflow
This commit is contained in:
parent
7ba0f297e5
commit
f3d50f273b
3 changed files with 74 additions and 4 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue