Skip to content

Commit caee1d6

Browse files
rjustogitster
authored andcommitted
branch: fix a leak in check_tracking_branch
Let's fix a leak we have in check_tracking_branch() since the function was introduced in 41c21f2 (branch.c: Validate tracking branches with refspecs instead of refs/remotes/*, 2013-04-21). The leak can be reviewed with: $ git remote add local . $ git update-ref refs/remotes/local/foo HEAD $ git branch --track bar local/foo Direct 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 check_tracking_branch branch.c ... in for_each_remote remote.c ... in validate_remote_tracking_branch branch.c ... in dwim_branch_start branch.c ... in create_branch branch.c ... in cmd_branch builtin/branch.c ... in run_builtin git.c Signed-off-by: Rubén Justo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a88a3d7 commit caee1d6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

branch.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,12 @@ static int check_tracking_branch(struct remote *remote, void *cb_data)
480480
{
481481
char *tracking_branch = cb_data;
482482
struct refspec_item query;
483+
int res;
483484
memset(&query, 0, sizeof(struct refspec_item));
484485
query.dst = tracking_branch;
485-
return !remote_find_tracking(remote, &query);
486+
res = !remote_find_tracking(remote, &query);
487+
free(query.src);
488+
return res;
486489
}
487490

488491
static int validate_remote_tracking_branch(char *ref)

0 commit comments

Comments
 (0)