Discovered using clang's MemorySanitizer when it ran python3's
test_fstring test_misformed_unicode_character_name.
An msan build will fail by simply executing: ./python -c 'u"\N"'
(cherry picked from commit
746b2d35ea47005054ed774fecaed64fab803d7d)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
--- /dev/null
+Fixed an out of bounds memory access when parsing a truncated unicode
+escape sequence at the end of a string such as ``'\N'``. It would read
+one byte beyond the end of the memory allocation.
}
message = "malformed \\N character escape";
- if (*s == '{') {
+ if (s < end && *s == '{') {
const char *start = ++s;
size_t namelen;
/* look for the closing brace */