From: Victor Stinner Date: Fri, 9 Oct 2015 01:37:11 +0000 (+0200) Subject: Issue #25318: Fix backslashreplace() X-Git-Tag: v3.6.0a1~1294 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3fa36ff5e4991550e31cc7ab55dc3a2165c2ffa3;p=thirdparty%2FPython%2Fcpython.git Issue #25318: Fix backslashreplace() Fix code to estimate the needed space. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 10cdcc0ec001..a3bbf9261f95 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -590,7 +590,7 @@ backslashreplace(_PyBytesWriter *writer, Py_ssize_t prealloc_per_char, incr = 2+4; else { assert(ch <= MAX_UNICODE); - incr = 2+6; + incr = 2+8; } if (size > PY_SSIZE_T_MAX - incr) { PyErr_SetString(PyExc_OverflowError,