aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-12-06 15:29:20 +0200
committerEli Zaretskii2019-12-06 15:29:20 +0200
commit1171fa32ca0bc7682b9fdc93babebc4c4feed104 (patch)
treec06d784814f09d2f3299b8b07eb6c93a1023be3f
parent48373e754034358b5afd8c2ed21d38278eb3141a (diff)
downloademacs-1171fa32ca0bc7682b9fdc93babebc4c4feed104.tar.gz
emacs-1171fa32ca0bc7682b9fdc93babebc4c4feed104.zip
Fix set-marker when the position is larger than the largest buffer
* src/marker.c (set_marker_internal): Handle the case where POSITION is beyond PTRDIFF_MAX, which can happen if Emacs was built --with-wide-int. Bug uncovered by the recently added overlay tests.
-rw-r--r--src/marker.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/marker.c b/src/marker.c
index 0b2e1bf5c6b..6358bc3bf79 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -529,7 +529,18 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position,
529 don't want to call buf_charpos_to_bytepos if POSITION 529 don't want to call buf_charpos_to_bytepos if POSITION
530 is a marker and so we know the bytepos already. */ 530 is a marker and so we know the bytepos already. */
531 if (FIXNUMP (position)) 531 if (FIXNUMP (position))
532 charpos = XFIXNUM (position), bytepos = -1; 532 {
533#if EMACS_INT_MAX > PTRDIFF_MAX
534 /* A --with-wide-int build. */
535 EMACS_INT cpos = XFIXNUM (position);
536 if (cpos > PTRDIFF_MAX)
537 cpos = PTRDIFF_MAX;
538 charpos = cpos;
539 bytepos = -1;
540#else
541 charpos = XFIXNUM (position), bytepos = -1;
542#endif
543 }
533 else if (MARKERP (position)) 544 else if (MARKERP (position))
534 { 545 {
535 charpos = XMARKER (position)->charpos; 546 charpos = XMARKER (position)->charpos;