diff options
| author | Eli Zaretskii | 2021-05-28 10:25:26 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2021-05-28 10:25:26 +0300 |
| commit | 3fe2f482bd2c636934cfd8e8aa0a07631164831d (patch) | |
| tree | 4b238d08b62b91bb0638a22982ffde9d2f071a91 /src | |
| parent | 5a264c3694dd5c2ecf0742d4d20147ac3448ef03 (diff) | |
| download | emacs-3fe2f482bd2c636934cfd8e8aa0a07631164831d.tar.gz emacs-3fe2f482bd2c636934cfd8e8aa0a07631164831d.zip | |
Attempt to fix segfaults caused by changes in 'lisp_string_width'
* src/character.c (lisp_string_width): Validate the value of TO
argument before passing it to 'composition_gstring_width'.
(Bug#48711)
Diffstat (limited to 'src')
| -rw-r--r-- | src/character.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/character.c b/src/character.c index 60424fab71e..e44ab8d43b1 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -376,9 +376,13 @@ lisp_string_width (Lisp_Object string, ptrdiff_t from, ptrdiff_t to, | |||
| 376 | && find_automatic_composition (i, -1, &ignore, &end, &val, string) | 376 | && find_automatic_composition (i, -1, &ignore, &end, &val, string) |
| 377 | && end > i) | 377 | && end > i) |
| 378 | { | 378 | { |
| 379 | int pixelwidth = composition_gstring_width (val, 0, | 379 | int j; |
| 380 | LGSTRING_GLYPH_LEN (val), | 380 | for (j = 0; j < LGSTRING_GLYPH_LEN (val); j++) |
| 381 | NULL); | 381 | if (NILP (LGSTRING_GLYPH (val, j))) |
| 382 | break; | ||
| 383 | |||
| 384 | int pixelwidth = composition_gstring_width (val, 0, j, NULL); | ||
| 385 | |||
| 382 | /* The below is somewhat expensive, so compute it only once | 386 | /* The below is somewhat expensive, so compute it only once |
| 383 | for the entire loop, and only if needed. */ | 387 | for the entire loop, and only if needed. */ |
| 384 | if (font_width < 0) | 388 | if (font_width < 0) |