summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-04-06 21:21:04 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2013-04-06 21:21:04 +0200
commiteefd845fb4a8d57b92d227b844dfd7fcc78573e5 (patch)
treeda1a810531e362786c529cd6c39e53d3d9ead987 /Python/compile.c
parent4500848e028866f76f582b3e4f29337b466bbdac (diff)
downloadcpython-eefd845fb4a8d57b92d227b844dfd7fcc78573e5.tar.gz
Issue #17645: convert an assert() into a proper exception in _Py_Mangle().
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 3cf71ef09e..0a8f58e692 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)