diff options
author | Eli Zaretskii <eliz@gnu.org> | 2019-12-06 15:29:20 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2019-12-06 15:29:20 +0200 |
commit | 1171fa32ca0bc7682b9fdc93babebc4c4feed104 (patch) | |
tree | c06d784814f09d2f3299b8b07eb6c93a1023be3f /src | |
parent | 48373e754034358b5afd8c2ed21d38278eb3141a (diff) | |
download | emacs-1171fa32ca0bc7682b9fdc93babebc4c4feed104.tar.gz emacs-1171fa32ca0bc7682b9fdc93babebc4c4feed104.tar.bz2 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/marker.c | 13 |
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, don't want to call buf_charpos_to_bytepos if POSITION is a marker and so we know the bytepos already. */ if (FIXNUMP (position)) - charpos = XFIXNUM (position), bytepos = -1; + { +#if EMACS_INT_MAX > PTRDIFF_MAX + /* A --with-wide-int build. */ + EMACS_INT cpos = XFIXNUM (position); + if (cpos > PTRDIFF_MAX) + cpos = PTRDIFF_MAX; + charpos = cpos; + bytepos = -1; +#else + charpos = XFIXNUM (position), bytepos = -1; +#endif + } else if (MARKERP (position)) { charpos = XMARKER (position)->charpos; |