summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2020-10-20 18:27:47 +0300
committerEli Zaretskii <eliz@gnu.org>2020-10-20 18:27:47 +0300
commitd3c3fe781424c866ad64ce9a8e3b649b30a0b5ae (patch)
tree7c2a6a85f3a9252d6d6383deab8feda76ec0665e /src
parent01e0357ba77031dfc66a00822a034e561c0c1ccc (diff)
downloademacs-d3c3fe781424c866ad64ce9a8e3b649b30a0b5ae.tar.gz
Avoid assertion violations in malformed Unicode escapes
* 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)
Diffstat (limited to 'src')
-rw-r--r--src/lread.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lread.c b/src/lread.c
index 4b788e99407..a3d5fd7bb81 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -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);