Skip to content
Permalink
Browse files

Avoid a segfault when python code fails

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 a1e826e4de08df240f81d2da4343e91ed3de66de
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/python/qgspythonutilsimpl.cpp
@@ -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 );

0 comments on commit a1e826e

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