diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2022-02-14 12:58:21 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-02-14 13:08:53 +0300 |
commit | e0fd31f083e0cd835635013a31fd3da6cf298ffa (patch) | |
tree | 9d5689228b0373b46baee35f2d3fbd887b0e33bb /source/blender/python/generic/idprop_py_ui_api.c | |
parent | 1236d2aea8d55c7d98409fc76968bad297a53007 (diff) |
Fix segfault calling `id_properties_ui("prop").update()`
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.
Diffstat (limited to 'source/blender/python/generic/idprop_py_ui_api.c')
-rw-r--r-- | source/blender/python/generic/idprop_py_ui_api.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/python/generic/idprop_py_ui_api.c b/source/blender/python/generic/idprop_py_ui_api.c index 37ba27f7315..321b2917c63 100644 --- a/source/blender/python/generic/idprop_py_ui_api.c +++ b/source/blender/python/generic/idprop_py_ui_api.c @@ -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); |