From: Serhiy Storchaka Date: Thu, 7 Feb 2013 14:26:55 +0000 (+0200) Subject: Issue #17043: The unicode-internal decoder no longer read past the end of X-Git-Tag: v3.4.0a1~1427 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0c79dcda56ce7cbcd1f72b0027fc151c86edfc7;p=thirdparty%2FPython%2Fcpython.git Issue #17043: The unicode-internal decoder no longer read past the end of input buffer. --- d0c79dcda56ce7cbcd1f72b0027fc151c86edfc7 diff --cc Objects/unicodeobject.c index cbd2870c1d73,abe793dfd487..8596e544233e --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@@ -6028,18 -6141,28 +6014,28 @@@ _PyUnicode_DecodeUnicodeInternal(const } #endif - if (unicode_putchar(&v, &outpos, ch) < 0) + if (_PyUnicodeWriter_Prepare(&writer, 1, ch) == -1) goto onError; + PyUnicode_WRITE(writer.kind, writer.data, writer.pos, ch); + writer.pos++; + continue; + + error: + startinpos = s - starts; - if (unicode_decode_call_errorhandler( ++ if (unicode_decode_call_errorhandler_writer( + errors, &errorHandler, + "unicode_internal", reason, + &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &outpos)) ++ &writer)) + goto onError; } - if (unicode_resize(&v, outpos) < 0) - goto onError; Py_XDECREF(errorHandler); Py_XDECREF(exc); - return unicode_result(v); + return _PyUnicodeWriter_Finish(&writer); onError: - Py_XDECREF(v); + _PyUnicodeWriter_Dealloc(&writer); Py_XDECREF(errorHandler); Py_XDECREF(exc); return NULL;