Fix memory leak in tuple-returning getters

This commit is contained in:
rdb 2015-07-06 10:31:33 +02:00
parent fe058dfb32
commit 69b8d6a4b5

View File

@ -6113,7 +6113,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
<< " return NULL;\n" << " return NULL;\n"
<< " }\n" << " }\n"
<< "\n" << "\n"
<< " PyObject *getter = PyObject_GetAttrString(self, \"" << element_name << "\");\n" << " PyObject *getter = PyDict_GetItemString(Dtool_" << ClassName << "._PyType.tp_dict, \"" << element_name << "\");\n"
<< " if (getter == (PyObject *)NULL) {\n" << " if (getter == (PyObject *)NULL) {\n"
<< " return NULL;\n" << " return NULL;\n"
<< " }\n" << " }\n"
@ -6127,7 +6127,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
<< "#else\n" << "#else\n"
<< " PyObject *index = PyInt_FromSsize_t(i);\n" << " PyObject *index = PyInt_FromSsize_t(i);\n"
<< "#endif\n" << "#endif\n"
<< " PyObject *value = PyObject_CallFunctionObjArgs(getter, index, NULL);\n" << " PyObject *value = PyObject_CallFunctionObjArgs(getter, self, index, NULL);\n"
<< " PyTuple_SET_ITEM(tuple, i, value);\n" << " PyTuple_SET_ITEM(tuple, i, value);\n"
<< " Py_DECREF(index);\n" << " Py_DECREF(index);\n"
<< " }\n" << " }\n"