From 494575fabf83372cce0ae7e87dc4656d8fa82dee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Feb 2009 14:24:44 +0000 Subject: [PATCH] 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. --- source/blender/editors/sculpt/sculpt.c | 9 +++------ source/blender/makesrna/intern/rna_define.c | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/sculpt/sculpt.c b/source/blender/editors/sculpt/sculpt.c index 757c20acc7c..2b0b5461bd3 100644 --- a/source/blender/editors/sculpt/sculpt.c +++ b/source/blender/editors/sculpt/sculpt.c @@ -1587,9 +1587,6 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) 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 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) /* 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); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 292c3c3d201..da3bc584266 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -999,7 +999,7 @@ void RNA_def_property_float_default(PropertyRNA *prop, float value) 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 @@ void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array) 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: