]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid assertion violations in STRING_CHAR
authorEli Zaretskii <eliz@gnu.org>
Tue, 4 Oct 2022 11:23:20 +0000 (14:23 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 4 Oct 2022 11:24:46 +0000 (14:24 +0300)
* 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)

src/editfns.c
src/xdisp.c

index 790f66e3a028e7fe3e4684c3936b4c863217d9d0..203d3a4a57f21e2276d3ca85e50349ef6268e95f 100644 (file)
@@ -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");
index f5f3a811e9d6fdc5287c620fc7dcad376b9d373f..0d0f77566bf2b99bcef6e5ae3b89634432bc2e17 100644 (file)
@@ -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
     {