PyAPI: fix memory leaks in dictionary assignment

Thanks to Kévin Dietrich for spotting driver leak,
checked other uses of PyDict_SetItem and found more.
This commit is contained in:
Campbell Barton
2016-07-14 17:28:28 +10:00
parent cca57bf04c
commit f5e020a7a6
7 changed files with 61 additions and 27 deletions

View File

@@ -163,7 +163,9 @@ void SCA_PythonController::SetNamespace(PyObject* pythondictionary)
/* Without __file__ set the sys.argv[0] is used for the filename
* which ends up with lines from the blender binary being printed in the console */
PyDict_SetItemString(m_pythondictionary, "__file__", PyUnicode_From_STR_String(m_scriptName));
PyObject *value = PyUnicode_From_STR_String(m_scriptName);
PyDict_SetItemString(m_pythondictionary, "__file__", value);
Py_DECREF(value);
}
#endif