diff Objects/unicodeobject.c @ 86477:f471f2f05621 3.3

Issue #19279: UTF-7 decoder no more produces illegal strings.
author Serhiy Storchaka <storchaka@gmail.com>
date Sat, 19 Oct 2013 20:38:19 +0300
parents ed8d94e4862a
children 7dde9c553f16
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Fri Oct 18 21:32:00 2013 -0700
+++ b/Objects/unicodeobject.c	Sat Oct 19 20:38:19 2013 +0300
@@ -4359,6 +4359,7 @@
                     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 @@
                 inShift = 1;
                 shiftOutStart = outpos;
                 base64bits = 0;
+                base64buffer = 0;
             }
         }
         else if (DECODE_DIRECT(ch)) { /* character decodes as itself */