Fix a python object leak in SWIG glue.

PyObject_CallFunction returns a PyObject which needs to be
decref'ed when it is no longer needed.

Patch by David Luyer
Differential Revision: https://reviews.llvm.org/D33740

llvm-svn: 305873
This commit is contained in:
Zachary Turner 2017-06-21 01:52:37 +00:00
parent ca48d369ba
commit 10a601adb2
1 changed files with 2 additions and 1 deletions

View File

@ -929,7 +929,8 @@ void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton);
void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton) {
if (baton != Py_None) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyObject_CallFunction(reinterpret_cast<PyObject*>(baton), const_cast<char*>("s"), str);
PyObject *result = PyObject_CallFunction(reinterpret_cast<PyObject*>(baton), const_cast<char*>("s"), str);
Py_XDECREF(result);
SWIG_PYTHON_THREAD_END_BLOCK;
}
}