From b2feb19c02e9efab537f849333c0b3d39188f950 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 02:06:19 +0000 Subject: fix for memory leak in transform when changing transform modes within transform (if you held down the R-key for example). --- source/blender/editors/transform/transform_input.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/transform/transform_input.c') diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index dd1510498b0..4e9a54692a5 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -307,15 +307,8 @@ static void calcSpringFactor(MouseInput *mi) void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) { - /* may have been allocated previously */ - /* TODO, holding R-key can cause mem leak, but this causes [#28903] - * disable for now. */ -#if 0 - if (mi->data) { - MEM_freeN(mi->data); - mi->data = NULL; - } -#endif + /* incase we allocate a new value */ + void *mi_data_prev = mi->data; switch (mode) { case INPUT_VECTOR: @@ -374,6 +367,12 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) break; } + /* if we've allocated new data, free the old data + * less hassle then checking before every alloc above */ + if (mi_data_prev && (mi_data_prev != mi->data)) { + MEM_freeN(mi_data_prev); + } + /* bootstrap mouse input with initial values */ applyMouseInput(t, mi, mi->imval, t->values); } -- cgit v1.2.3