diff options
author | Eli Zaretskii <eliz@gnu.org> | 2022-10-04 14:23:20 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-10-04 14:24:46 +0300 |
commit | b560ce3560fc1559a08667798710cf37af0e079a (patch) | |
tree | e173e6bcfa4135e621ade3009397e5cb30c0be93 /src | |
parent | 78c262e1c2cf93d3101cb942926d170a816a8d3f (diff) | |
download | emacs-b560ce3560fc1559a08667798710cf37af0e079a.tar.gz |
Avoid assertion violations in STRING_CHAR
* src/xdisp.c (handle_composition_prop):
* src/editfns.c (styled_format): Don't call 'STRING_CHAR' on
unibyte strings. This avoids assertion violation in
'string_char_and_length'.
(cherry picked from commit d52d6e1e106117eb4bba81a65e256e2e793037b6)
Diffstat (limited to 'src')
-rw-r--r-- | src/editfns.c | 4 | ||||
-rw-r--r-- | src/xdisp.c | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/editfns.c b/src/editfns.c index 790f66e3a02..203d3a4a57f 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3468,7 +3468,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) || conversion == 'o' || conversion == 'x' || conversion == 'X')) error ("Invalid format operation %%%c", - STRING_CHAR ((unsigned char *) format - 1)); + multibyte_format + ? STRING_CHAR ((unsigned char *) format - 1) + : *((unsigned char *) format - 1)); else if (! (FIXNUMP (arg) || ((BIGNUMP (arg) || FLOATP (arg)) && conversion != 'c'))) error ("Format specifier doesn't match argument type"); diff --git a/src/xdisp.c b/src/xdisp.c index f5f3a811e9d..0d0f77566bf 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -6034,7 +6034,10 @@ handle_composition_prop (struct it *it) pos_byte = IT_STRING_BYTEPOS (*it); string = it->string; s = SDATA (string) + pos_byte; - it->c = STRING_CHAR (s); + if (STRING_MULTIBYTE (string)) + it->c = STRING_CHAR (s); + else + it->c = *s; } else { |