Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix major(?) memory leak with python code execution
(cherry-picked from 73733a6)
- Loading branch information
@@ -298,9 +298,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 ); | ||
This comment has been minimized.
This comment has been minimized.
elpaso
Contributor
|
||
|
||
// we are done calling python API, release global interpreter lock | ||
PyGILState_Release( gstate ); | ||
@@ -581,6 +581,8 @@ bool QgsPythonUtilsImpl::evalString( const QString& command, QString& result ) | ||
if ( success ) | ||
result = PyObjectToQString( res ); | ||
|
||
Py_XDECREF( res ); | ||
This comment has been minimized. |
||
|
||
// we are done calling python API, release global interpreter lock | ||
PyGILState_Release( gstate ); | ||
|
||
Segfault here with 2.14.3
test with
qgis --code 'some_not_existant_path.py'