[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18783] branches/blender2.5/blender/source /blender: sculpt operator was setting default array value from stack variables that were then freed , making sculpt defaults use invalid memory.
Campbell Barton
ideasman42 at gmail.com
Sun Feb 1 15:24:45 CET 2009
Revision: 18783
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18783
Author: campbellbarton
Date: 2009-02-01 15:24:44 +0100 (Sun, 01 Feb 2009)
Log Message:
-----------
sculpt operator was setting default array value from stack variables that were then freed, making sculpt defaults use invalid memory.
Since these values defaulted to zero, a NULL default array will do, but for new operators that need to be initialized from an array, only static arrays should be used.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
Modified: branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c 2009-02-01 13:52:11 UTC (rev 18782)
+++ branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c 2009-02-01 14:24:44 UTC (rev 18783)
@@ -1587,9 +1587,6 @@
static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
{
- float vec3f_def[] = {0,0,0};
- int vec2i_def[] = {0,0};
-
ot->flag |= OPTYPE_REGISTER;
/* identifiers */
@@ -1610,15 +1607,15 @@
/* If the object has a scaling factor, brushes also need to be scaled
to work as expected. */
- RNA_def_float_vector(ot->srna, "scale", 3, vec3f_def, 0.0f, FLT_MAX, "Scale", "", 0.0f, 1000.0f);
+ RNA_def_float_vector(ot->srna, "scale", 3, NULL, 0.0f, FLT_MAX, "Scale", "", 0.0f, 1000.0f);
RNA_def_int(ot->srna, "flag", 0, 0, INT_MAX, "flag", "", 0, INT_MAX);
/* For mirror modifiers */
- RNA_def_float_vector(ot->srna, "clip_tolerance", 3, vec3f_def, 0.0f, FLT_MAX, "clip_tolerance", "", 0.0f, 1000.0f);
+ RNA_def_float_vector(ot->srna, "clip_tolerance", 3, NULL, 0.0f, FLT_MAX, "clip_tolerance", "", 0.0f, 1000.0f);
/* The initial 2D location of the mouse */
- RNA_def_int_vector(ot->srna, "initial_mouse", 2, vec2i_def, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX);
+ RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX);
/* The initial screen depth of the mouse */
RNA_def_float(ot->srna, "depth", 0.0f, 0.0f, FLT_MAX, "depth", "", 0.0f, FLT_MAX);
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c 2009-02-01 13:52:11 UTC (rev 18782)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c 2009-02-01 14:24:44 UTC (rev 18783)
@@ -999,7 +999,7 @@
break;
}
}
-
+/* array must remain valid after this function finishes */
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
{
StructRNA *srna= DefRNA.laststruct;
@@ -1007,7 +1007,7 @@
switch(prop->type) {
case PROP_FLOAT: {
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
- fprop->defaultarray= array;
+ fprop->defaultarray= array; /* WARNING, this array must not come from the stack and lost */
break;
}
default:
More information about the Bf-blender-cvs
mailing list