From c4b5279bbca4db2ee88e0451fe6d41175e26719a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Wed, 22 Jan 2020 11:17:34 +0100 Subject: Fix T72894: Mantaflow: several crashes due to null pointers Incorporated LazyDodo's suggestions from the task. --- intern/mantaflow/intern/MANTA_main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index 79363126aff..a1851da711a 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -2057,7 +2057,10 @@ static char *pyObjectToString(PyObject *inputObject) PyObject *encoded = PyUnicode_AsUTF8String(inputObject); char *result = PyBytes_AsString(encoded); - Py_DECREF(encoded); + + /* Do not decref (i.e. Py_DECREF(encoded)) of string 'encoded' PyObject. + * Otherwise those objects will be invalidated too early (see T72894). + * Reference count of those Python objects will be decreased with 'del' in Python scripts. */ Py_DECREF(inputObject); PyGILState_Release(gilstate); -- cgit v1.2.3