From 35804e4c63ae0a61adb71ced8ea6ddcf68908d41 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 19 Oct 2013 20:38:19 +0300 Subject: Issue #19279: UTF-7 decoder no more produces illegal strings. --- Objects/unicodeobject.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Objects/unicodeobject.c') diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 440d35ad0c..a149177a09 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4359,6 +4359,7 @@ PyUnicode_DecodeUTF7Stateful(const char *s, Py_UCS4 outCh = (Py_UCS4)(base64buffer >> (base64bits-16)); base64bits -= 16; base64buffer &= (1 << base64bits) - 1; /* clear high bits */ + assert(outCh <= 0xffff); if (surrogate) { /* expecting a second surrogate */ if (Py_UNICODE_IS_LOW_SURROGATE(outCh)) { @@ -4426,6 +4427,7 @@ PyUnicode_DecodeUTF7Stateful(const char *s, inShift = 1; shiftOutStart = outpos; base64bits = 0; + base64buffer = 0; } } else if (DECODE_DIRECT(ch)) { /* character decodes as itself */ -- cgit v1.2.1