summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fns.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/fns.c b/src/fns.c
index 8c512039788..32ec031bf46 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3140,7 +3140,7 @@ If the region can't be decoded, return nil and don't modify the buffer.")
old_pos += inserted_chars - (XFASTINT (end) - XFASTINT (beg));
else if (old_pos > XFASTINT (beg))
old_pos = XFASTINT (beg);
- SET_PT (old_pos);
+ SET_PT (old_pos > ZV ? ZV : old_pos);
return make_number (inserted_chars);
}