diff options
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index c77751d..23268f9 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2671,7 +2671,10 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, startinpos = s-starts; /* \ - Escapes */ s++; - switch (*s++) { + c = *s++; + if (s > end) + c = '\0'; /* Invalid after \ */ + switch (c) { /* \x escapes */ case '\n': break; @@ -2690,9 +2693,9 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': x = s[-1] - '0'; - if ('0' <= *s && *s <= '7') { + if (s < end && '0' <= *s && *s <= '7') { x = (x<<3) + *s++ - '0'; - if ('0' <= *s && *s <= '7') + if (s < end && '0' <= *s && *s <= '7') x = (x<<3) + *s++ - '0'; } *p++ = x; |