diff options
author | Glen Choo <chooglen@google.com> | 2022-01-29 03:04:46 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-04 19:16:39 +0300 |
commit | 679e3693aba0c17af60c031f7eef68f2296b8dad (patch) | |
tree | d4b4abf14888f03eb49d12aab825b0d1142b0f4b | |
parent | 961b130d20c9aea322b94a639a63ec8cca9f14fc (diff) |
branch.c: use 'goto cleanup' in setup_tracking() to fix memory leaks
Signed-off-by: Glen Choo <chooglen@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | branch.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -239,7 +239,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref, if (track != BRANCH_TRACK_INHERIT) for_each_remote(find_tracked_branch, &tracking); else if (inherit_tracking(&tracking, orig_ref)) - return; + goto cleanup; if (!tracking.matches) switch (track) { @@ -249,7 +249,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref, case BRANCH_TRACK_INHERIT: break; default: - return; + goto cleanup; } if (tracking.matches > 1) @@ -262,7 +262,8 @@ static void setup_tracking(const char *new_ref, const char *orig_ref, tracking.remote, tracking.srcs) < 0) exit(-1); - string_list_clear(tracking.srcs, 0); +cleanup: + string_list_clear(&tracking_srcs, 0); } int read_branch_desc(struct strbuf *buf, const char *branch_name) |