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.
This commit is contained in:
Campbell Barton
2009-02-01 14:24:44 +00:00
parent dafc620a75
commit 494575fabf
2 changed files with 5 additions and 8 deletions

View File

@@ -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);

View File

@@ -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: