Kaydet (Commit) 55bff891 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

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

üst e8f706ed
...@@ -248,8 +248,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident) ...@@ -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)
......
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