Discovered using clang's MemorySanitizer.
A msan build will fail by simply executing: ./python -c 'u"\N"'
(cherry picked from commit
746b2d3)
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
--- /dev/null
+Fixed an out of bounds memory access when parsing a truncated unicode escape
+sequence at the end of a string such as ``u'\N'``. It would read one byte
+beyond the end of the memory allocation.
if (ucnhash_CAPI == NULL)
goto ucnhashError;
}
- if (*s == '{') {
+ if (s < end && *s == '{') {
const char *start = s+1;
/* look for the closing brace */
while (*s != '}' && s < end)