From 619fb173df99ce4466cbde0e6e07567464f3a478 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 18 Jun 2017 16:20:12 +0200 Subject: [PATCH] fix crash when argument list of openTransaction() is empty --- src/App/DocumentPyImp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index ce7bda4983..249fe4e0a9 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -326,18 +326,21 @@ PyObject* DocumentPy::moveObject(PyObject *args) PyObject* DocumentPy::openTransaction(PyObject *args) { - PyObject *value; + PyObject *value = 0; if (!PyArg_ParseTuple(args, "|O",&value)) return NULL; // NULL triggers exception std::string cmd; + if (!value) { + cmd = ""; + } #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_Check(value)) { + else if (PyUnicode_Check(value)) { cmd = PyUnicode_AsUTF8(value); } #else - if (PyUnicode_Check(value)) { + else if (PyUnicode_Check(value)) { PyObject* unicode = PyUnicode_AsLatin1String(value); cmd = PyString_AsString(unicode); Py_DECREF(unicode);