Skip to content
Permalink
Browse files

Fix major(?) memory leak with python code execution

  • Loading branch information
nyalldawson committed May 10, 2016
1 parent c32966d commit 73733a65edd2bbc8156bf36484995457c35f6b68
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/python/qgspythonutilsimpl.cpp
@@ -305,9 +305,9 @@ bool QgsPythonUtilsImpl::runStringUnsafe( const QString& command, bool single )
// TODO: convert special characters from unicode strings u"..." to \uXXXX
// so that they're not mangled to utf-8
// (non-unicode strings can be mangled)
PyRun_String( command.toUtf8().data(), single ? Py_single_input : Py_file_input, mMainDict, mMainDict );

PyObject* obj = PyRun_String( command.toUtf8().data(), single ? Py_single_input : Py_file_input, mMainDict, mMainDict );
bool res = nullptr == PyErr_Occurred();
Py_DECREF( obj );

// we are done calling python API, release global interpreter lock
PyGILState_Release( gstate );
@@ -580,6 +580,8 @@ bool QgsPythonUtilsImpl::evalString( const QString& command, QString& result )
if ( success )
result = PyObjectToQString( res );

Py_XDECREF( res );

// we are done calling python API, release global interpreter lock
PyGILState_Release( gstate );

0 comments on commit 73733a6

Please sign in to comment.
You can’t perform that action at this time.