]> git.eshelyaron.com Git - emacs.git/commitdiff
Attempt to fix segfaults caused by changes in 'lisp_string_width'
authorEli Zaretskii <eliz@gnu.org>
Fri, 28 May 2021 07:25:26 +0000 (10:25 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 28 May 2021 07:25:26 +0000 (10:25 +0300)
* src/character.c (lisp_string_width): Validate the value of TO
argument before passing it to 'composition_gstring_width'.
(Bug#48711)

src/character.c

index 60424fab71e6bbaa0ce6734d6c02b19f9e39693a..e44ab8d43b18c969e12a135e30a7e5f3aa839ecd 100644 (file)
@@ -376,9 +376,13 @@ lisp_string_width (Lisp_Object string, ptrdiff_t from, ptrdiff_t to,
               && find_automatic_composition (i, -1, &ignore, &end, &val, string)
               && end > i)
        {
-         int pixelwidth = composition_gstring_width (val, 0,
-                                                     LGSTRING_GLYPH_LEN (val),
-                                                     NULL);
+         int j;
+         for (j = 0; j < LGSTRING_GLYPH_LEN (val); j++)
+           if (NILP (LGSTRING_GLYPH (val, j)))
+             break;
+
+         int pixelwidth = composition_gstring_width (val, 0, j, NULL);
+
          /* The below is somewhat expensive, so compute it only once
             for the entire loop, and only if needed.  */
          if (font_width < 0)