UI: fix access of freed memory in buttons handling code.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 18 May 2011 15:23:40 +0000 (15:23 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 18 May 2011 15:23:40 +0000 (15:23 +0000)
source/blender/editors/interface/interface_handlers.c

index e2910d33b12db1227579314ea95483b9cef67eb5..759301cc8f347c1da2e8428308c6ce7bb962896f 100644 (file)
@@ -298,7 +298,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
                after->func_arg3= but->func_arg3;
 
                after->funcN= but->funcN;
-               after->func_argN= but->func_argN;
+               after->func_argN= MEM_dupallocN(but->func_argN);
 
                after->rename_func= but->rename_func;
                after->rename_arg1= but->rename_arg1;
@@ -402,6 +402,8 @@ static void ui_apply_but_funcs_after(bContext *C)
                        after.func(C, after.func_arg1, after.func_arg2);
                if(after.funcN)
                        after.funcN(C, after.func_argN, after.func_arg2);
+               if(after.func_argN)
+                       MEM_freeN(after.func_argN);
                
                if(after.handle_func)
                        after.handle_func(C, after.handle_func_arg, after.retval);