Skip to content

Commit

Permalink
Avoid a segfault when python code fails
Browse files Browse the repository at this point in the history
PyRun_StringFlags: Returns the result of executing
the code as a Python object, or NULL if an exception was raised.
  • Loading branch information
elpaso committed May 23, 2016
1 parent 5a74c68 commit a1e826e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/python/qgspythonutilsimpl.cpp
Expand Up @@ -300,7 +300,10 @@ bool QgsPythonUtilsImpl::runStringUnsafe( const QString& command, bool single )
// (non-unicode strings can be mangled)
PyObject* obj = PyRun_String( command.toUtf8().data(), single ? Py_single_input : Py_file_input, mMainDict, mMainDict );
bool res = nullptr == PyErr_Occurred();
Py_DECREF( obj );
if ( obj )
{
Py_DECREF( obj );
}

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

0 comments on commit a1e826e

Please sign in to comment.