obs-scripting: Fix script_path() python mem corruption

Returning PyObject with borrowed reference will result in double free
and/or use after free issue.  Issue seen as crash when running Python
script calling script_path().
This commit is contained in:
Per Heed 2020-09-13 22:32:55 +02:00 committed by jp9000
parent 32bb14ddea
commit 318779be7a

View file

@ -147,8 +147,13 @@ void add_functions_to_py_module(PyObject *module, PyMethodDef *method_list)
static PyObject *py_get_current_script_path(PyObject *self, PyObject *args)
{
PyObject *dir;
UNUSED_PARAMETER(args);
return PyDict_GetItemString(PyModule_GetDict(self), "__script_dir__");
dir = PyDict_GetItemString(PyModule_GetDict(self), "__script_dir__");
Py_XINCREF(dir);
return dir;
}
static void get_defaults(struct obs_python_script *data, PyObject *get_defs)