summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/_ctypes/_ctypes.c4
-rw-r--r--Modules/_ctypes/callbacks.c1
2 files changed, 3 insertions, 2 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index ac4859ee05..daaec022fe 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3191,8 +3191,10 @@ CFuncPtr_clear(CFuncPtrObject *self)
Py_CLEAR(self->converters);
Py_CLEAR(self->paramflags);
- if (self->thunk)
+ if (self->thunk) {
FreeCallback(self->thunk);
+ PyMem_Free(self->thunk);
+ }
self->thunk = NULL;
return CData_clear((CDataObject *)self);
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 286faa3518..4b1ca58483 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -292,7 +292,6 @@ static void closure_fcn(ffi_cif *cif,
void FreeCallback(THUNK thunk)
{
FreeClosure(((ffi_info *)thunk)->pcl);
- PyMem_Free(thunk);
}
THUNK AllocFunctionCallback(PyObject *callable,