]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #17645: convert an assert() into a proper exception in _Py_Mangle().
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 6 Apr 2013 19:21:04 +0000 (21:21 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 6 Apr 2013 19:21:04 +0000 (21:21 +0200)
Python/compile.c

index 3cf71ef09e2d27b3e93fbd16be1558f406d4aca7..0a8f58e692d81a1b6801a46cedb8fc787102f938 100644 (file)
@@ -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)