diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-04-06 19:21:04 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-04-06 19:21:04 (GMT) |
commit | 022db598acdc33a7c026322a25b54ff594f54042 (patch) | |
tree | dea37b39085c4e62089517cd57555a84afba1e59 /Python/compile.c | |
parent | 0e7df4312893db22f70de5d74ad56ef7a4f36746 (diff) | |
download | cpython-022db598acdc33a7c026322a25b54ff594f54042.zip cpython-022db598acdc33a7c026322a25b54ff594f54042.tar.gz cpython-022db598acdc33a7c026322a25b54ff594f54042.tar.bz2 |
Issue #17645: convert an assert() into a proper exception in _Py_Mangle().
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index 531bed4..8354c75 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) |