Skip to content

Commit 9df9bdd

Browse files
committed
Merge branch 'bc/checkout-tracking-name-plug-leak'
Plug a small leak in checkout. * bc/checkout-tracking-name-plug-leak: t/t9802: explicitly name the upstream branch to use as a base builtin/checkout.c: don't leak memory in check_tracking_name
2 parents fa4bf9e + 9d58c4a commit 9df9bdd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

builtin/checkout.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,13 +838,16 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
838838
memset(&query, 0, sizeof(struct refspec));
839839
query.src = cb->src_ref;
840840
if (remote_find_tracking(remote, &query) ||
841-
get_sha1(query.dst, cb->dst_sha1))
841+
get_sha1(query.dst, cb->dst_sha1)) {
842+
free(query.dst);
842843
return 0;
844+
}
843845
if (cb->dst_ref) {
846+
free(query.dst);
844847
cb->unique = 0;
845848
return 0;
846849
}
847-
cb->dst_ref = xstrdup(query.dst);
850+
cb->dst_ref = query.dst;
848851
return 0;
849852
}
850853

t/t9802-git-p4-filetype.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test_expect_success 'gitattributes setting eol=lf produces lf newlines' '
9595
git init &&
9696
echo "* eol=lf" >.gitattributes &&
9797
git p4 sync //depot@all &&
98-
git checkout master &&
98+
git checkout -b master p4/master &&
9999
test_cmp "$cli"/f-unix-orig f-unix &&
100100
test_cmp "$cli"/f-win-as-lf f-win
101101
)
@@ -109,7 +109,7 @@ test_expect_success 'gitattributes setting eol=crlf produces crlf newlines' '
109109
git init &&
110110
echo "* eol=crlf" >.gitattributes &&
111111
git p4 sync //depot@all &&
112-
git checkout master &&
112+
git checkout -b master p4/master &&
113113
test_cmp "$cli"/f-unix-as-crlf f-unix &&
114114
test_cmp "$cli"/f-win-orig f-win
115115
)

0 commit comments

Comments
 (0)