diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-04-06 19:21:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-04-06 19:21:46 (GMT) |
commit | 7d8c29a02219b06559b290e5ca0ab12d072892b0 (patch) | |
tree | 0178f099867299473d549471e82b5b855648bd14 /Python/compile.c | |
parent | aac81e2780a181f4076190a28cde3e4bfaab614b (diff) | |
parent | 55bff8919031093dad249be793d24c66956d8af3 (diff) | |
download | cpython-7d8c29a02219b06559b290e5ca0ab12d072892b0.zip cpython-7d8c29a02219b06559b290e5ca0ab12d072892b0.tar.gz cpython-7d8c29a02219b06559b290e5ca0ab12d072892b0.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 0aca8bd..842ed50 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -248,8 +248,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident) } plen -= ipriv; - 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; + } maxchar = PyUnicode_MAX_CHAR_VALUE(ident); if (PyUnicode_MAX_CHAR_VALUE(privateobj) > maxchar) |