Skip to content

Commit 5ace483

Browse files
rjustogitster
authored andcommitted
branch: fix a leak in setup_tracking
In bdaf1df (branch: new autosetupmerge option "simple" for matching branches, 2022-04-29) a new exit for setup_tracking() missed the clean-up, producing a leak. $ git config branch.autoSetupMerge simple $ git remote add local . $ git update-ref refs/remotes/local/foo HEAD $ git branch bar local/foo Direct leak of 384 byte(s) in 1 object(s) allocated from: ... in xrealloc wrapper.c ... in string_list_append_nodup string-list.c ... in find_tracked_branch branch.c ... in for_each_remote remote.c ... in setup_tracking branch.c ... in create_branch branch.c ... in cmd_branch builtinbranch.c ... in run_builtin git.c Indirect leak of 24 byte(s) in 1 object(s) allocated from: ... in xrealloc wrapper.c ... in strbuf_grow strbuf.c ... in strbuf_add strbuf.c ... in match_name_with_pattern remote.c ... in query_refspecs remote.c ... in remote_find_tracking remote.c ... in find_tracked_branch branch.c ... in for_each_remote remote.c ... in setup_tracking branch.c ... in create_branch branch.c ... in cmd_branch builtinbranch.c ... in run_builtin git.c The return introduced in bdaf1df was to avoid setting up the tracking, but even in that case it is still necessary to do the clean-up. Let's do it. Signed-off-by: Rubén Justo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05e717d commit 5ace483

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
333333
if (!skip_prefix(tracking.srcs->items[0].string,
334334
"refs/heads/", &tracked_branch) ||
335335
strcmp(tracked_branch, new_ref))
336-
return;
336+
goto cleanup;
337337
}
338338

339339
if (tracking.srcs->nr < 1)

0 commit comments

Comments
 (0)