Fix T38650: Crash from enum item functions returning NULL instead of a

single terminator item.

Ideally no enum item function should return NULL, but since this is very
common and an intuitive mistake, better handle that case gracefully in
the RNA access function.
This commit is contained in:
Lukas Tönne 2014-02-17 12:15:42 +01:00
parent d39ffd7217
commit 280f9d3b39
Notes: blender-bot 2023-02-14 11:11:04 +01:00
Referenced by issue #38650, Frequent segfault when loading attached Blender file with compositor node setup
1 changed files with 7 additions and 6 deletions

View File

@ -1222,18 +1222,19 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En
*r_free = false;
if (eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
int tot = 0;
if (prop->flag & PROP_ENUM_NO_CONTEXT)
*item = eprop->itemf(NULL, ptr, prop, r_free);
else
*item = eprop->itemf(C, ptr, prop, r_free);
if (r_totitem) {
if (*item) {
for (; (*item)[tot].identifier; tot++) ;
}
if ((*item) == NULL) {
int tot = 0;
RNA_enum_item_end(item, &tot);
}
if (r_totitem) {
int tot = 0;
for (; (*item)[tot].identifier; tot++) ;
*r_totitem = tot;
}