summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-04-06 19:21:04 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-04-06 19:21:04 (GMT)
commit55bff8919031093dad249be793d24c66956d8af3 (patch)
tree90c5410e8449019114e74582819dd4a3f818542f
parente8f706eda77db200728fc436dca20f0591eeec27 (diff)
downloadcpython-55bff8919031093dad249be793d24c66956d8af3.zip
cpython-55bff8919031093dad249be793d24c66956d8af3.tar.gz
cpython-55bff8919031093dad249be793d24c66956d8af3.tar.bz2
Issue #17645: convert an assert() into a proper exception in _Py_Mangle().
-rw-r--r--Python/compile.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 3cf71ef..0a8f58e 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)