target/target: free what leaked in target_destroy() 12/4412/2
authorTomas Vanek <vanekt@fbl.cz>
Thu, 15 Feb 2018 00:24:50 +0000 (01:24 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Thu, 15 Mar 2018 17:09:30 +0000 (17:09 +0000)
Free event_action, fileio_info and working area.

Change-Id: Iac81230423e92304b8e2c971d0ec71a96b693fc4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4412
Tested-by: jenkins
src/target/target.c

index 32000c0..bd9d56b 100644 (file)
@@ -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);
 }