From: Antoine Pitrou Date: Sat, 6 Apr 2013 19:21:04 +0000 (+0200) Subject: Issue #17645: convert an assert() into a proper exception in _Py_Mangle(). X-Git-Tag: v2.7.5~101 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=022db598acdc33a7c026322a25b54ff594f54042;p=thirdparty%2FPython%2Fcpython.git Issue #17645: convert an assert() into a proper exception in _Py_Mangle(). --- diff --git a/Python/compile.c b/Python/compile.c index 531bed43c481..8354c75b3932 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -221,8 +221,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident) } plen = strlen(p); - assert(1 <= PY_SSIZE_T_MAX - nlen); - assert(1 + nlen <= PY_SSIZE_T_MAX - plen); + if (plen + nlen >= PY_SSIZE_T_MAX - 1) { + PyErr_SetString(PyExc_OverflowError, + "private identifier too large to be mangled"); + return NULL; + } ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen); if (!ident)