From: Gregory Heytings Date: Mon, 18 Jul 2022 14:04:04 +0000 (+0000) Subject: Shorter and safer fix for the segfault. X-Git-Tag: emacs-29.0.90~1447^2~821^2~9 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6a097a86210cf1226d432b255cc41aa74fe93507;p=emacs.git Shorter and safer fix for the segfault. * src/xdisp.c (get_visually_first_element): Shorter and safer fix for the segfault. Improves the fix introduced in cc7f37b2a4. --- diff --git a/src/xdisp.c b/src/xdisp.c index d69d7440bc0..572ad2b8540 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -8668,18 +8668,11 @@ get_visually_first_element (struct it *it) bool string_p = STRINGP (it->string) || it->s; ptrdiff_t eob = (string_p ? it->bidi_it.string.schars : ZV); ptrdiff_t bob; + ptrdiff_t obegv = BEGV; - SET_WITH_NARROWED_BEGV (it, bob, string_p ? 0 : BEGV); - - /* Reseat again when, as a consequence of the SET_WITH_NARROWED_BEGV - above, the iterator is before bob. */ - if (!string_p && IT_CHARPOS (*it) < bob) - { - struct text_pos pos; - pos.charpos = bob; - pos.bytepos = CHAR_TO_BYTE (bob); - reseat (it, pos, true); - } + SET_WITH_NARROWED_BEGV (it, bob, + string_p ? 0 : + IT_BYTEPOS (*it) < BEGV ? obegv : BEGV); if (STRINGP (it->string)) {