Skip to content

Commit ab18508

Browse files
committed
Some bugs solved from python port and loader related to the number of arguments in the callback.
1 parent ecc7f8d commit ab18508

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

source/loaders/py_loader/source/py_loader_impl.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,17 @@ function_return function_py_interface_invoke(function func, function_impl impl,
11561156
loader_impl_py py_impl = loader_impl_get(py_func->impl);
11571157
PyGILState_STATE gstate = PyGILState_Ensure();
11581158
PyObject *tuple_args;
1159+
void ** values;
1160+
11591161
/* Allocate dynamically more space for values in case of variable arguments */
1160-
void ** values = args_size > signature_args_size ? malloc(sizeof(void *) * args_size) : py_func->values;
1162+
if (args_size > signature_args_size || py_func->values == NULL)
1163+
{
1164+
values = malloc(sizeof(void *) * args_size);
1165+
}
1166+
else
1167+
{
1168+
values = py_func->values;
1169+
}
11611170

11621171
/* Possibly a recursive call */
11631172
if (Py_EnterRecursiveCall(" while executing a function in Python Loader") != 0)
@@ -1205,7 +1214,7 @@ function_return function_py_interface_invoke(function func, function_impl impl,
12051214
Py_DECREF(tuple_args);
12061215

12071216
/* Variable arguments */
1208-
if (args_size > signature_args_size)
1217+
if (args_size > signature_args_size || py_func->values == NULL)
12091218
{
12101219
free(values);
12111220
}

source/loaders/py_loader/source/py_loader_port.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ static PyObject * py_loader_port_invoke(PyObject * self, PyObject * var_args)
367367

368368
if (value_args != NULL)
369369
{
370-
ret = metacallv(name_str, value_args);
370+
ret = metacallv_s(name_str, value_args, args_size);
371371
}
372372
else
373373
{
374-
ret = metacallv(name_str, metacall_null_args);
374+
ret = metacallv_s(name_str, metacall_null_args, 0);
375375
}
376376

377377
PyEval_RestoreThread(thread_state);

0 commit comments

Comments
 (0)