]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds.
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Jan 2013 20:43:18 +0000 (22:43 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Jan 2013 20:43:18 +0000 (22:43 +0200)
Objects/unicodeobject.c

index b4c37fb464050f42a454e007a543d2d26ae57438..7713b5497e1d7f920ca43565084107bf8a5f3600 100644 (file)
@@ -2272,7 +2272,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
     /* On narrow builds we split characters outside the BMP into two
        codepoints => count how much extra space we need. */
 #ifndef Py_UNICODE_WIDE
-    for (qq = q; qq < e; qq += 4)
+    for (qq = q; e - qq >= 4; qq += 4)
         if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0)
             pairs++;
 #endif