diff options
author | Eli Zaretskii <eliz@gnu.org> | 2016-09-06 19:46:06 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2016-09-06 19:46:06 +0300 |
commit | 644f77b517180c5f75a9eaac4d76b12a1f334ce6 (patch) | |
tree | ecdbd5a36616cbc954ccd4e3de2e2ae8e039bb0e /src/marker.c | |
parent | dcfcc595339f8bd503dedf95976b8a3633382f4f (diff) | |
download | emacs-644f77b517180c5f75a9eaac4d76b12a1f334ce6.tar.gz |
Avoid assertion violations when using marker positions
* src/intervals.c (set_point_from_marker): If MARKER comes from
another buffer, recalculate its byte position before using it to
set point.
* src/marker.c (set_marker_internal): If POSITION is a marker from
another buffer, recalculate its byte position before using it.
(Bug#24368)
Diffstat (limited to 'src/marker.c')
-rw-r--r-- | src/marker.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/marker.c b/src/marker.c index febdb17689a..05e5bb87474 100644 --- a/src/marker.c +++ b/src/marker.c @@ -507,7 +507,11 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position, charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos, restricted ? BUF_ZV (b) : BUF_Z (b)); - if (bytepos == -1) + /* Don't believe BYTEPOS if it comes from a different buffer, + since that buffer might have a very different correspondence + between character and byte positions. */ + if (bytepos == -1 + || !(MARKERP (position) && XMARKER (position)->buffer == b)) bytepos = buf_charpos_to_bytepos (b, charpos); else bytepos = clip_to_bounds |