Issue #16335: Fix integer overflow in unicode-escape decoder.

This commit is contained in:
Serhiy Storchaka 2013-01-21 11:44:40 +02:00
commit 6481bfb2b5
2 changed files with 18 additions and 1 deletions

View file

@ -5569,7 +5569,8 @@ PyUnicode_DecodeUnicodeEscape(const char *s,
/* found a name. look it up in the unicode database */
message = "unknown Unicode character name";
s++;
if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1),
if (s - start - 1 <= INT_MAX &&
ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1),
&chr, 0))
goto store;
}