Skip to content

Commit

Permalink
check result of PyMem_Malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed Nov 23, 2024
1 parent 223d650 commit b6d454a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Modules/_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1661,9 +1661,13 @@ methodcaller_vectorcall(
}

assert(mc->vectorcall_args != 0);
number_of_arguments++;
PyObject **tmp_args = (PyObject **) PyMem_Malloc(number_of_arguments * sizeof(PyObject *));
memcpy(tmp_args, mc->vectorcall_args, sizeof(PyObject *) * number_of_arguments );
size_t buffer_size = sizeof(PyObject *) * (number_of_arguments + 1);
PyObject **tmp_args = (PyObject **) PyMem_Malloc buffer_size);
if (tmp_args == NULL) {
PyErr_NoMemory();
return -1;
}
memcpy(tmp_args, mc->vectorcall_args, buffer_size);
tmp_args[0] = args[0];
return PyObject_VectorcallMethod(
mc->name, tmp_args,
Expand Down

0 comments on commit b6d454a

Please sign in to comment.