Commit 7dc18a70 authored by Benjamin Peterson's avatar Benjamin Peterson

use PyMem_NEW to detect overflow (closes #23362)

parent 73c1241f
...@@ -8501,7 +8501,7 @@ _PyUnicode_TranslateCharmap(PyObject *input, ...@@ -8501,7 +8501,7 @@ _PyUnicode_TranslateCharmap(PyObject *input,
/* allocate enough for a simple 1:1 translation without /* allocate enough for a simple 1:1 translation without
replacements, if we need more, we'll resize */ replacements, if we need more, we'll resize */
osize = size; osize = size;
output = PyMem_Malloc(osize * sizeof(Py_UCS4)); output = PyMem_NEW(Py_UCS4, osize);
opos = 0; opos = 0;
if (output == NULL) { if (output == NULL) {
PyErr_NoMemory(); PyErr_NoMemory();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment