[Bf-blender-cvs] [90c19c6] master: Fix memory leak when assigning driver

Julian Eisel noreply at git.blender.org
Thu Mar 31 16:45:49 CEST 2016


Commit: 90c19c61d4d24286fe323e115017d900f055dd98
Author: Julian Eisel
Date:   Thu Mar 31 16:41:50 2016 +0200
Branches: master
https://developer.blender.org/rB90c19c61d4d24286fe323e115017d900f055dd98

Fix memory leak when assigning driver

Also added NULL-checks for RNA paths, though they might be a bit paranoid.

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

M	source/blender/editors/interface/interface_eyedropper.c

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

diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 39e41c5..1684c95 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -1136,18 +1136,26 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
 		char *dst_path    = BKE_animdata_driver_path_hack(C, &ddr->ptr, ddr->prop, NULL);
 		
 		/* Now create driver(s) */
-		int success = ANIM_add_driver_with_target(op->reports,
-		                                          ddr->ptr.id.data, dst_path, ddr->index,
-		                                          target_ptr->id.data, target_path, target_index,
-		                                          flag, DRIVER_TYPE_PYTHON, mapping_type);
-		
-		if (success) {
-			/* send updates */
-			UI_context_update_anim_flag(C);
-			DAG_relations_tag_update(CTX_data_main(C));
-			DAG_id_tag_update(ddr->ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA);
-			WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL);  // XXX
+		if (target_path && dst_path) {
+			int success = ANIM_add_driver_with_target(op->reports,
+			                                          ddr->ptr.id.data, dst_path, ddr->index,
+			                                          target_ptr->id.data, target_path, target_index,
+			                                          flag, DRIVER_TYPE_PYTHON, mapping_type);
+			
+			if (success) {
+				/* send updates */
+				UI_context_update_anim_flag(C);
+				DAG_relations_tag_update(CTX_data_main(C));
+				DAG_id_tag_update(ddr->ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA);
+				WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL);  // XXX
+			}
 		}
+		
+		/* cleanup */
+		if (target_path)
+			MEM_freeN(target_path);
+		if (dst_path)
+			MEM_freeN(dst_path);
 	}
 }




More information about the Bf-blender-cvs mailing list