diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-08 21:14:24 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-08 21:14:24 (GMT) |
commit | 48e188e57313813bd048e25b8fa6123b8cd5c9a0 (patch) | |
tree | 3d5b4dacb7995a82e1057a7fa4dc1ed7d8dc8c5c /Objects | |
parent | dec798eb46f7edfe0995ce1b8966097fb7567eb7 (diff) | |
download | cpython-48e188e57313813bd048e25b8fa6123b8cd5c9a0.zip cpython-48e188e57313813bd048e25b8fa6123b8cd5c9a0.tar.gz cpython-48e188e57313813bd048e25b8fa6123b8cd5c9a0.tar.bz2 |
Issue #11461: Fix the incremental UTF-16 decoder. Original patch by
Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP
characters.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 7cd0399..7f86bfd 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3573,8 +3573,11 @@ PyUnicode_DecodeUTF16Stateful(const char *s, /* UTF-16 code pair: */ if (e - q < 2) { + q -= 2; + if (consumed) + break; errmsg = "unexpected end of data"; - startinpos = (((const char *)q) - 2) - starts; + startinpos = ((const char *)q) - starts; endinpos = ((const char *)e) - starts; goto utf16Error; } |