]> 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:23:20 +0000 (14:23 +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'.

src/editfns.c
src/xdisp.c

index b774e79337f456e241883f9f2f57ce75d13f2ffc..c1414071c790f9695d325ad05584b358bf36ee41 100644 (file)
@@ -3552,7 +3552,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 818cf5e3f8f6a33085755b0a8d8219525d33cbfc..9534e27843e6f7c0399007a8ef1e5e8309973f3b 100644 (file)
@@ -6312,7 +6312,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
     {