[Python-checkins] cpython (2.7): Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds.

serhiy.storchaka python-checkins at python.org
Tue Jan 8 21:47:18 CET 2013


http://hg.python.org/cpython/rev/3570e04f4ea9
changeset:   81326:3570e04f4ea9
branch:      2.7
parent:      81322:1d8effd379c3
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Jan 08 22:43:18 2013 +0200
summary:
  Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds.

files:
  Objects/unicodeobject.c |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2272,7 +2272,7 @@
     /* 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list