[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52553] trunk/blender/source/blender: fix for uninitialized memory use with numeric input:
Campbell Barton
ideasman42 at gmail.com
Mon Nov 26 04:47:28 CET 2012
Revision: 52553
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52553
Author: campbellbarton
Date: 2012-11-26 03:47:20 +0000 (Mon, 26 Nov 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
trunk/blender/source/blender/editors/animation/anim_markers.c
trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c
trunk/blender/source/blender/editors/mesh/editmesh_tools.c
trunk/blender/source/blender/editors/util/numinput.c
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h 2012-11-26 03:16:29 UTC (rev 52552)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h 2012-11-26 03:47:20 UTC (rev 52553)
@@ -185,7 +185,7 @@
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);
Modified: trunk/blender/source/blender/editors/animation/anim_markers.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_markers.c 2012-11-26 03:16:29 UTC (rev 52552)
+++ trunk/blender/source/blender/editors/animation/anim_markers.c 2012-11-26 03:47:20 UTC (rev 52553)
@@ -860,16 +860,21 @@
}
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);
Modified: trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c 2012-11-26 03:16:29 UTC (rev 52552)
+++ trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c 2012-11-26 03:47:20 UTC (rev 52553)
@@ -552,9 +552,9 @@
/* 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
Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2012-11-26 03:16:29 UTC (rev 52552)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2012-11-26 03:47:20 UTC (rev 52553)
@@ -4973,9 +4973,9 @@
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 @@
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 @@
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]);
Modified: trunk/blender/source/blender/editors/util/numinput.c
===================================================================
--- trunk/blender/source/blender/editors/util/numinput.c 2012-11-26 03:16:29 UTC (rev 52552)
+++ trunk/blender/source/blender/editors/util/numinput.c 2012-11-26 03:47:20 UTC (rev 52553)
@@ -130,6 +130,9 @@
return 0;
}
+/**
+ * \warning \a vec must be set beforehand otherwise we risk uninitialized vars.
+ */
void applyNumInput(NumInput *n, float *vec)
{
short i, j;
More information about the Bf-blender-cvs
mailing list