[PyQt] [PATCH] Fix memory leak when Python function returns char *
Gavin Li
gavin at matician.com
Tue Oct 16 01:34:17 BST 2018
Hello folks,
I found a memory leak in SIP where if C++ calls a wrapped Python
function that returns (char *), the object return would get leaked.
sip_api_keep_reference() already keeps a reference to the returned
object, and the extraneous Py_INCREF() keeps the object from ever
getting deallocated.
I found this memory leak when trying to subclass QAbstractVideoBuffer
and implementing its abstract map() method in Python.
Gavin
Index: sip/siplib/siplib.c
===================================================================
--- sip.orig/siplib/siplib.c
+++ sip/siplib/siplib.c
@@ -3261,7 +3261,6 @@ static int parseResult(PyObject *method,
}
else
{
- Py_INCREF(arg);
sip_api_keep_reference((PyObject *)py_self, key, arg);
}
}
More information about the PyQt
mailing list