Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check result of PyMem_Malloc
  • Loading branch information
eendebakpt committed Nov 23, 2024
commit b6d454a730b12bb55cfd562dedff4ca06069cba0
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