Skip to content

Commit eeb0d4e

Browse files
committed
Consistently pass the size to getfunc/setfunc
1 parent ab237ff commit eeb0d4e

File tree

4 files changed

+78
-5
lines changed

4 files changed

+78
-5
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ c_void_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
19701970
return NULL;
19711971
parg->pffi_type = &ffi_type_pointer;
19721972
parg->tag = 'P';
1973-
parg->obj = fd->setfunc(&parg->value, value, 0);
1973+
parg->obj = fd->setfunc(&parg->value, value, sizeof(void*));
19741974
if (parg->obj == NULL) {
19751975
Py_DECREF(parg);
19761976
return NULL;
@@ -2430,7 +2430,7 @@ PyCSimpleType_from_param_impl(PyObject *type, PyTypeObject *cls,
24302430

24312431
parg->tag = fmt[0];
24322432
parg->pffi_type = fd->pffi_type;
2433-
parg->obj = fd->setfunc(&parg->value, value, 0);
2433+
parg->obj = fd->setfunc(&parg->value, value, info->size);
24342434
if (parg->obj)
24352435
return (PyObject *)parg;
24362436
PyObject *exc = PyErr_GetRaisedException();

Modules/_ctypes/callbacks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static void _CallPythonObject(ctypes_state *st,
264264
be the result. EXCEPT when restype is py_object - Python
265265
itself knows how to manage the refcount of these objects.
266266
*/
267-
PyObject *keep = setfunc(mem, result, 0);
267+
PyObject *keep = setfunc(mem, result, restype->size);
268268

269269
if (keep == NULL) {
270270
/* Could not convert callback result. */

0 commit comments

Comments
 (0)