Skip to content

Commit c9d281f

Browse files
MinyazevRusiems
authored andcommitted
Fix memory leak with PyDict_Copy
1 parent 9d56817 commit c9d281f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/PythonQtInstanceWrapper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name)
383383
}
384384

385385
if (qstrcmp(attributeName, "__dict__")==0) {
386-
PyObject* dict = PyBaseObject_Type.tp_getattro(obj, name);
387-
dict = PyDict_Copy(dict);
386+
PyObject* objectDict = PyBaseObject_Type.tp_getattro(obj, name);
387+
PyObject* dict = PyDict_Copy(objectDict);
388+
Py_DECREF(objectDict);
388389

389390
if (wrapper->_obj) {
390391
// we need to replace the properties with their real values...

0 commit comments

Comments
 (0)