[Bf-blender-cvs] [1d15421] master: Fix T47477: Transform allows 'inf' input

Campbell Barton noreply at git.blender.org
Fri Feb 19 00:44:14 CET 2016


Commit: 1d15421af97980e4a149490fe31a325fed070853
Author: Campbell Barton
Date:   Fri Feb 19 10:19:19 2016 +1100
Branches: master
https://developer.blender.org/rB1d15421af97980e4a149490fe31a325fed070853

Fix T47477: Transform allows 'inf' input

Numeric input wasn't checking numbers were finite,
could crash transforming with skin modifier.

===================================================================

M	source/blender/editors/util/numinput.c

===================================================================

diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 9bb4e05..e078313 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -477,6 +477,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 
 	/* At this point, our value has changed, try to interpret it with python (if str is not empty!). */
 	if (n->str[0]) {
+		const float val_prev = n->val[idx];
 #ifdef WITH_PYTHON
 		Scene *sce = CTX_data_scene(C);
 		double val;
@@ -514,6 +515,11 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 		if (n->val_flag[idx] & NUM_INVERSE) {
 			n->val[idx] = 1.0f / n->val[idx];
 		}
+
+		if (UNLIKELY(!isfinite(n->val[idx]))) {
+			n->val[idx] = val_prev;
+			n->val_flag[idx] |= NUM_INVALID;
+		}
 	}
 
 	/* REDRAW SINCE NUMBERS HAVE CHANGED */




More information about the Bf-blender-cvs mailing list