Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d8c29a

Browse files
committed
Issue #17645: convert an assert() into a proper exception in _Py_Mangle().
2 parents aac81e2 + 55bff89 commit 7d8c29a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Python/compile.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
248248
}
249249
plen -= ipriv;
250250

251-
assert(1 <= PY_SSIZE_T_MAX - nlen);
252-
assert(1 + nlen <= PY_SSIZE_T_MAX - plen);
251+
if (plen + nlen >= PY_SSIZE_T_MAX - 1) {
252+
PyErr_SetString(PyExc_OverflowError,
253+
"private identifier too large to be mangled");
254+
return NULL;
255+
}
253256

254257
maxchar = PyUnicode_MAX_CHAR_VALUE(ident);
255258
if (PyUnicode_MAX_CHAR_VALUE(privateobj) > maxchar)

0 commit comments

Comments
 (0)