diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-07 14:03:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-07 14:03:14 +0400 |
commit | b218d901766305d322f1cadd4422c9efe2271495 (patch) | |
tree | 4cf0e4591f552974aed0684e413a5c18c350c79b /source/blender/python | |
parent | b9c441536c7859ba6b26f3f90e281ee22dda147a (diff) |
fix a crash when python is registering enum properties and the `items` argument is a generator (some sequence type besides a list/typle), in this case it could free the strings before blender duplicates them.
this fixes [#32192] Import Images as Planes script is broken
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index a781dbb33b5..f9c39ad24b0 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1298,9 +1298,8 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) eitems = enum_items_from_py(items_fast, def, &defvalue, (opts & PROP_ENUM_FLAG) != 0); - Py_DECREF(items_fast); - if (!eitems) { + Py_DECREF(items_fast); return NULL; } } @@ -1327,6 +1326,10 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_duplicate_pointers(srna, prop); if (is_itemf == FALSE) { + /* note: this must be postponed until after #RNA_def_property_duplicate_pointers + * otherwise if this is a generator it may free the strings before we get copy them */ + Py_DECREF(items_fast); + MEM_freeN(eitems); } } |