textview: Don't overflow

Both numbers are unsigned, so the result is always unsigned.
(Which also means ABS() doing a < 0 check doesn't work.)
And that in particular means that end - begin overflows to a very
large number when begin > end.
This commit is contained in:
Benjamin Otte
2024-10-21 06:43:09 +02:00
parent 5637b3ba20
commit 4fcdcc2e50

View File

@@ -1194,7 +1194,7 @@ gtk_text_history_text_deleted (GtkTextHistory *self,
action->u.delete.end = end;
action->u.delete.selection.insert = self->selection.insert;
action->u.delete.selection.bound = self->selection.bound;
istring_set (&action->u.delete.istr, text, len, ABS (end - begin));
istring_set (&action->u.delete.istr, text, len, MAX (end, begin) - MIN (end, begin));
gtk_text_history_push (self, action);
}