Issue #14579: Fix error handling bug in the utf-16 decoder.

Patch by Serhiy Storchaka.
This commit is contained in:
Antoine Pitrou 2012-07-21 00:52:06 +02:00
parent bee739baa7
commit 715a63b783
3 changed files with 30 additions and 3 deletions

View file

@ -2564,7 +2564,7 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
}
/* UTF-16 code pair: */
if (q >= e) {
if (e - q < 2) {
errmsg = "unexpected end of data";
startinpos = (((const char *)q)-2)-starts;
endinpos = ((const char *)e)-starts;