Mercurial > pub > dyncall > bindings
changeset 66:7a61dd082341 default tip
pydc:
- fix double free triggered by capsule destructor, when freeing pydc and callback objects, manually
author | Tassilo Philipp |
---|---|
date | Fri, 24 May 2024 18:16:29 +0200 |
parents | 75a4082f0fce |
children | |
files | python/pydc/pydc.c |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/python/pydc/pydc.c Sun May 19 15:45:13 2024 +0200 +++ b/python/pydc/pydc.c Fri May 24 18:16:29 2024 +0200 @@ -28,7 +28,7 @@ # define USE_CAPSULE_API # define DcPyCObject_FromVoidPtr(ptr, dtor) PyCapsule_New((ptr), NULL, (dtor)) // !new ref! # define DcPyCObject_AsVoidPtr(ppobj) PyCapsule_GetPointer((ppobj), NULL) -# define DcPyCObject_SetVoidPtr(ppobj, ptr) //@@@ unsure what to do, cannot/shouldn't call this with a null pointer as this wants to call the dtor, so not doing anything: PyCapsule_SetPointer((ppobj), (ptr)) // this might need to call the dtor to behave like PyCObject_SetVoidPtr? +# define DcPyCObject_SetVoidPtr(ppobj, ptr) PyCapsule_SetDestructor((ppobj), NULL) // just remove the dtor (this allows for free_callback) to be called, explicitly # define DcPyCObject_Check(ppobj) PyCapsule_CheckExact((ppobj)) #endif @@ -764,7 +764,7 @@ DcPyCObject_SetVoidPtr(pcobj, NULL); //don't think I need to release it, as the pyobj is not equivalent to the held handle - //Py_XDECREF(pcobj); // release ref from pydc_load() + //Py_XDECREF(pcobj); // release ref from pydc_new_callback() Py_RETURN_NONE; }