]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
use PyMem_NEW to detect overflow (closes #23362)
authorBenjamin Peterson <benjamin@python.org>
Mon, 2 Mar 2015 18:23:25 +0000 (13:23 -0500)
committerBenjamin Peterson <benjamin@python.org>
Mon, 2 Mar 2015 18:23:25 +0000 (13:23 -0500)
Objects/unicodeobject.c

index 156316b1543263b6f6d11922bfa57aded6d4695c..2bc34c5730769580cf3e7b26023ff72895320f2a 100644 (file)
@@ -8501,7 +8501,7 @@ _PyUnicode_TranslateCharmap(PyObject *input,
     /* allocate enough for a simple 1:1 translation without
        replacements, if we need more, we'll resize */
     osize = size;
-    output = PyMem_Malloc(osize * sizeof(Py_UCS4));
+    output = PyMem_NEW(Py_UCS4, osize);
     opos = 0;
     if (output == NULL) {
         PyErr_NoMemory();