Commit 1171fa32 authored by Eli Zaretskii's avatar Eli Zaretskii

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.
parent 48373e75
......@@ -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;
......
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