Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-26 07:47:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-26 07:47:20 +0400
commite77e1f183ae6732eadda82ba1d7ab9975a9224f8 (patch)
tree080f565b65e74203b8f7bf6717bb6d9c27251195 /source
parent3d64381e4de22c8c65177b8f8d1b541284ae4483 (diff)
fix for uninitialized memory use with numeric input:
bevel/inset/marker-move would use uninitialized memory when used as modal operators and pressing backspace after entering values.
Diffstat (limited to 'source')
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h2
-rw-r--r--source/blender/editors/animation/anim_markers.c21
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c8
-rw-r--r--source/blender/editors/util/numinput.c3
5 files changed, 22 insertions, 14 deletions
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index 1f6e44e9320..acbc765f0df 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -185,7 +185,7 @@ BLI_INLINE int BMO_slot_map_bool_get(BMOpSlot *slot, const void *element)
return 0;
}
-BLI_INLINE void *BMO_slot_map_ptr_get_(BMOpSlot *slot, const void *element)
+BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
{
void **val = (void **) BMO_slot_map_data_get(slot, element);
BLI_assert(slot->slot_subtype == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 4ac7b61fccb..d595034032e 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -860,16 +860,21 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
}
if (evt->val == KM_PRESS) {
- float vec;
- char str_tx[NUM_STR_REP_LEN];
-
if (handleNumInput(&mm->num, evt)) {
- applyNumInput(&mm->num, &vec);
- outputNumInput(&mm->num, str_tx);
-
- RNA_int_set(op->ptr, "frames", vec);
+ char str_tx[NUM_STR_REP_LEN];
+ float value = RNA_int_get(op->ptr, "frames");
+ applyNumInput(&mm->num, &value);
+
+ if (hasNumInput(&mm->num)) {
+ outputNumInput(&mm->num, str_tx);
+ }
+ else {
+ BLI_snprintf(str_tx, sizeof(str_tx), "%d", (int)value);
+ }
+
+ RNA_int_set(op->ptr, "frames", value);
ed_marker_move_apply(C, op);
- // ed_marker_header_update(C, op, str, (int)vec[0]);
+ // ed_marker_header_update(C, op, str, (int)value);
// strcat(str, str_tx);
BLI_snprintf(str, sizeof(str), "Marker offset %s", str_tx);
ED_area_headerprint(CTX_wm_area(C), str);
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index f951073155d..fcfb12a09bf 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -552,9 +552,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
/* using the keyboard to input the number of cuts */
if (event->val == KM_PRESS) {
/* init as zero so backspace clears */
- float value = 0.0f;
if (handleNumInput(&lcd->num, event)) {
+ float value = RNA_int_get(op->ptr, "number_cuts");
applyNumInput(&lcd->num, &value);
/* allow zero so you can backspace and type in a value
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 507b93d959f..9dd7c1c5bdf 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -4973,9 +4973,9 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
if (event->val == KM_PRESS) {
/* Try to handle numeric inputs... */
#ifdef NEW_BEVEL
- float value;
if (handleNumInput(&opdata->num_input, event)) {
+ float value = RNA_float_get(op->ptr, "offset");
applyNumInput(&opdata->num_input, &value);
RNA_float_set(op->ptr, "offset", value);
edbm_bevel_calc(C, op);
@@ -4983,9 +4983,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
#else
- float factor;
-
if (handleNumInput(&opdata->num_input, event)) {
+ float factor = RNA_float_get(op->ptr, "percent");
applyNumInput(&opdata->num_input, &factor);
CLAMP(factor, 0.0f, 1.0f);
RNA_float_set(op->ptr, "percent", factor);
@@ -5365,9 +5364,10 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
if (event->val == KM_PRESS) {
/* Try to handle numeric inputs... */
- float amounts[2];
if (handleNumInput(&opdata->num_input, event)) {
+ float amounts[2] = {RNA_float_get(op->ptr, "thickness"),
+ RNA_float_get(op->ptr, "depth")};
applyNumInput(&opdata->num_input, amounts);
amounts[0] = max_ff(amounts[0], 0.0f);
RNA_float_set(op->ptr, "thickness", amounts[0]);
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index b73f5fa0869..0ec16ead35d 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -130,6 +130,9 @@ short hasNumInput(NumInput *n)
return 0;
}
+/**
+ * \warning \a vec must be set beforehand otherwise we risk uninitialized vars.
+ */
void applyNumInput(NumInput *n, float *vec)
{
short i, j;