From: Tomas Vanek Date: Thu, 15 Feb 2018 00:24:50 +0000 (+0100) Subject: target/target: free what leaked in target_destroy() X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7ad11de2fa37b504fc84f608ee355cf02221429a;p=openocd target/target: free what leaked in target_destroy() Free event_action, fileio_info and working area. Change-Id: Iac81230423e92304b8e2c971d0ec71a96b693fc4 Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/4412 Tested-by: jenkins --- diff --git a/src/target/target.c b/src/target/target.c index 32000c04..bd9d56b0 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1892,8 +1892,24 @@ static void target_destroy(struct target *target) if (target->type->deinit_target) target->type->deinit_target(target); + struct target_event_action *teap = target->event_action; + while (teap) { + struct target_event_action *next = teap->next; + Jim_DecrRefCount(teap->interp, teap->body); + free(teap); + teap = next; + } + + target_free_all_working_areas(target); + /* Now we have none or only one working area marked as free */ + if (target->working_areas) { + free(target->working_areas->backup); + free(target->working_areas); + } + free(target->type); free(target->trace_info); + free(target->fileio_info); free(target->cmd_name); free(target); }