[PATCH v7 6/6] branch.c: use 'goto cleanup' in setup_tracking() to fix memory leaks
Signed-off-by: Glen Choo <chooglen@google.com>
---
branch.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/branch.c b/branch.c
index be33fe09fa..1e9a585633 100644
--- a/branch.c
+++ b/branch.c
@@ -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,6 +262,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
tracking.remote, tracking.srcs) < 0)
exit(-1);
+cleanup:
string_list_clear(tracking.srcs, 0);
}
--
2.33.GIT