Commit 7b502dc3 authored by Jim Blandy's avatar Jim Blandy
Browse files

* cmds.c (Fforward_char): Check proposed new position, and then

	set point, instead of setting point to a potentially invalid
parent 52f8ec73
...@@ -41,17 +41,28 @@ On reaching end of buffer, stop and signal error.") ...@@ -41,17 +41,28 @@ On reaching end of buffer, stop and signal error.")
else else
SET_PT (point + XINT (n)); /* This used to just set point to point + XINT (n), and then check
if (point < BEGV) to see if it was within boundaries. But now that SET_PT can
{ potentially do a lot of stuff (calling entering and exiting
SET_PT (BEGV); hooks, etcetera), that's not a good approach. So we validate the
Fsignal (Qbeginning_of_buffer, Qnil); proposed position, then set point. */
} {
if (point > ZV) int new_point = point + XINT (n);
SET_PT (ZV); if (new_point < BEGV)
Fsignal (Qend_of_buffer, Qnil); {
Fsignal (Qbeginning_of_buffer, Qnil);
if (new_point > ZV)
Fsignal (Qend_of_buffer, Qnil);
SET_PT (new_point);
return Qnil; return Qnil;
} }
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