Skip to content

Commit

Permalink
Fix segfault calling id_properties_ui("prop").update()
Browse files Browse the repository at this point in the history
Fix segfault when calling `some_id.id_properties_ui("propname").update()`,
i.e. call the `update()` function without any keyword arguments. In such
a case, Python passes `kwargs = NULL`, but `PyDict_Contains()` is not
`NULL`-safe.
  • Loading branch information
drsybren committed Feb 14, 2022
1 parent 1236d2a commit e0fd31f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/blender/python/generic/idprop_py_ui_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@

static bool args_contain_key(PyObject *kwargs, const char *name)
{
if (kwargs == NULL) {
/* When a function gets called without any kwargs, Python just passes NULL instead.
* PyDict_Contains() is not NULL-safe, though. */
return false;
}

PyObject *py_key = PyUnicode_FromString(name);
const bool result = PyDict_Contains(kwargs, py_key) == 1;
Py_DECREF(py_key);
Expand Down

0 comments on commit e0fd31f

Please sign in to comment.