Issue #17645: convert an assert() into a proper exception in _Py_Mangle().

This commit is contained in:
Antoine Pitrou 2013-04-06 21:21:04 +02:00
parent e8f706eda7
commit 55bff89190
1 changed files with 5 additions and 2 deletions

View File

@ -248,8 +248,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
} }
plen -= ipriv; plen -= ipriv;
assert(1 <= PY_SSIZE_T_MAX - nlen); if (plen + nlen >= PY_SSIZE_T_MAX - 1) {
assert(1 + nlen <= PY_SSIZE_T_MAX - plen); PyErr_SetString(PyExc_OverflowError,
"private identifier too large to be mangled");
return NULL;
}
maxchar = PyUnicode_MAX_CHAR_VALUE(ident); maxchar = PyUnicode_MAX_CHAR_VALUE(ident);
if (PyUnicode_MAX_CHAR_VALUE(privateobj) > maxchar) if (PyUnicode_MAX_CHAR_VALUE(privateobj) > maxchar)