Kaydet (Commit) 022db598 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

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

üst 0e7df431
...@@ -221,8 +221,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident) ...@@ -221,8 +221,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
} }
plen = strlen(p); plen = strlen(p);
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;
}
ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen); ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen);
if (!ident) if (!ident)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment