[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] [PATCH] Fix memory leak when Python function returns char *
From:       Gavin Li <gavin () matician ! com>
Date:       2018-10-16 0:34:17
Message-ID: CACB127+WjOdO+nkyx+_12DOZ-7SmNnxrxNGoHGT8JAeNZOt1Fg () mail ! gmail ! com
[Download RAW message or body]

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);
                     }
                 }
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic