[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49644] trunk/blender/source/blender/ python/intern/bpy_props.c: 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.

Campbell Barton ideasman42 at gmail.com
Tue Aug 7 12:03:14 CEST 2012


Revision: 49644
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49644
Author:   campbellbarton
Date:     2012-08-07 10:03:14 +0000 (Tue, 07 Aug 2012)
Log Message:
-----------
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

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_props.c

Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c	2012-08-07 10:02:34 UTC (rev 49643)
+++ trunk/blender/source/blender/python/intern/bpy_props.c	2012-08-07 10:03:14 UTC (rev 49644)
@@ -1298,9 +1298,8 @@
 			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 @@
 		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);
 		}
 	}




More information about the Bf-blender-cvs mailing list