]> 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 531bed43c4815c8b31099af57056c450f489d01e..8354c75b393222317e6cb2fa2a30475eb2a0bb17 100644 (file)
@@ -221,8 +221,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
     }
     plen = strlen(p);
 
-    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;
+    }
 
     ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen);
     if (!ident)