]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid assertion violations in malformed Unicode escapes
authorEli Zaretskii <eliz@gnu.org>
Tue, 20 Oct 2020 15:27:47 +0000 (18:27 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 20 Oct 2020 15:27:47 +0000 (18:27 +0300)
* src/lread.c (read_escape): Produce better diagnostic for
malformed \u Unicode escapes, while avoiding assertion violation
when READCHAR returns -1 because the input is exhausted.
(Bug#44084)

src/lread.c

index 4b788e99407dc8fa68ebbaf5e655849dd686f17c..a3d5fd7bb81b471d89a069bdcd6e7a719c8bfe89 100644 (file)
@@ -2573,6 +2573,13 @@ read_escape (Lisp_Object readcharfun, bool stringp)
        while (++count <= unicode_hex_count)
          {
            c = READCHAR;
+           if (c < 0)
+             {
+               if (unicode_hex_count > 4)
+                 error ("Malformed Unicode escape: \\U%x", i);
+               else
+                 error ("Malformed Unicode escape: \\u%x", i);
+             }
            /* `isdigit' and `isalpha' may be locale-specific, which we don't
               want.  */
            int digit = char_hexdigit (c);