From: Serhiy Storchaka Date: Tue, 8 Jan 2013 20:45:42 +0000 (+0200) Subject: Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds. X-Git-Tag: v3.3.1rc1~411^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dec798eb46f7edfe0995ce1b8966097fb7567eb7;p=python Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index f8c738bc75..7cd039990c 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3182,7 +3182,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