Commit 98546d9c authored by Paul Eggert's avatar Paul Eggert

Fix integer overflow in internal_self_insert

* src/cmds.c (internal_self_insert): Avoid undefined behavior
on integer overflow by using saturated add.
parent e4b6151f
......@@ -451,7 +451,10 @@ internal_self_insert (int c, EMACS_INT n)
string = concat2 (string, tem);
}
replace_range (PT, PT + chars_to_delete, string, 1, 1, 1, 0);
ptrdiff_t to;
if (INT_ADD_WRAPV (PT, chars_to_delete, &to))
to = PTRDIFF_MAX;
replace_range (PT, to, string, 1, 1, 1, 0);
Fforward_char (make_fixnum (n));
}
else if (n > 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment