From 90c19c61d4d24286fe323e115017d900f055dd98 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 31 Mar 2016 16:41:50 +0200 Subject: Fix memory leak when assigning driver Also added NULL-checks for RNA paths, though they might be a bit paranoid. --- .../editors/interface/interface_eyedropper.c | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to '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 39e41c57c03..1684c954eae 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); } } -- cgit v1.2.3