Avoid a potential double-free bug.

This commit is contained in:
Thomas Heller 2006-03-20 14:22:05 +00:00
parent ba29e4c573
commit e502693ee9
2 changed files with 3 additions and 2 deletions

View File

@ -3191,8 +3191,10 @@ CFuncPtr_clear(CFuncPtrObject *self)
Py_CLEAR(self->converters); Py_CLEAR(self->converters);
Py_CLEAR(self->paramflags); Py_CLEAR(self->paramflags);
if (self->thunk) if (self->thunk) {
FreeCallback(self->thunk); FreeCallback(self->thunk);
PyMem_Free(self->thunk);
}
self->thunk = NULL; self->thunk = NULL;
return CData_clear((CDataObject *)self); return CData_clear((CDataObject *)self);

View File

@ -292,7 +292,6 @@ static void closure_fcn(ffi_cif *cif,
void FreeCallback(THUNK thunk) void FreeCallback(THUNK thunk)
{ {
FreeClosure(((ffi_info *)thunk)->pcl); FreeClosure(((ffi_info *)thunk)->pcl);
PyMem_Free(thunk);
} }
THUNK AllocFunctionCallback(PyObject *callable, THUNK AllocFunctionCallback(PyObject *callable,