diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-06-27 14:29:46 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-06-27 14:29:46 -0700 |
commit | 9df9bdda3a2450fe97ba4db61ce4d46c81fbfc16 (patch) | |
tree | bd38118591f281343c33e9aa9f98428eef23cbb4 | |
parent | fa4bf9edb9300da2688da8a920c506376a14de0a (diff) | |
parent | 9d58c4a3e3ce3a40262b7ff3cc39ce3b9a93d527 (diff) | |
download | git-9df9bdda3a2450fe97ba4db61ce4d46c81fbfc16.tar.gz git-9df9bdda3a2450fe97ba4db61ce4d46c81fbfc16.tar.xz |
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
-rw-r--r-- | builtin/checkout.c | 7 | ||||
-rwxr-xr-x | t/t9802-git-p4-filetype.sh | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index f5b50e520..3be001882 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -838,13 +838,16 @@ static int check_tracking_name(struct remote *remote, void *cb_data) memset(&query, 0, sizeof(struct refspec)); query.src = cb->src_ref; if (remote_find_tracking(remote, &query) || - get_sha1(query.dst, cb->dst_sha1)) + get_sha1(query.dst, cb->dst_sha1)) { + free(query.dst); return 0; + } if (cb->dst_ref) { + free(query.dst); cb->unique = 0; return 0; } - cb->dst_ref = xstrdup(query.dst); + cb->dst_ref = query.dst; return 0; } diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh index eeefa6790..b0d1d94bf 100755 --- a/t/t9802-git-p4-filetype.sh +++ b/t/t9802-git-p4-filetype.sh @@ -95,7 +95,7 @@ test_expect_success 'gitattributes setting eol=lf produces lf newlines' ' git init && echo "* eol=lf" >.gitattributes && git p4 sync //depot@all && - git checkout master && + git checkout -b master p4/master && test_cmp "$cli"/f-unix-orig f-unix && test_cmp "$cli"/f-win-as-lf f-win ) @@ -109,7 +109,7 @@ test_expect_success 'gitattributes setting eol=crlf produces crlf newlines' ' git init && echo "* eol=crlf" >.gitattributes && git p4 sync //depot@all && - git checkout master && + git checkout -b master p4/master && test_cmp "$cli"/f-unix-as-crlf f-unix && test_cmp "$cli"/f-win-orig f-win ) |