diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-05-23 13:46:05 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-23 13:46:05 +0900 |
commit | e40c0f428837d9a1e23dc711b0632c99455810af (patch) | |
tree | f84771a6365c7d7470421e15a786ca15aa6264aa /builtin/checkout.c | |
parent | Merge branch 'ls/travis-relays-for-windows-ci' (diff) | |
parent | am: check return value of resolve_refdup before using hash (diff) | |
download | tgif-e40c0f428837d9a1e23dc711b0632c99455810af.tar.xz |
Merge branch 'rs/checkout-am-fix-unborn'
A few codepaths in "checkout" and "am" working on an unborn branch
tried to access an uninitialized piece of memory.
* rs/checkout-am-fix-unborn:
am: check return value of resolve_refdup before using hash
checkout: check return value of resolve_refdup before using hash
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index bfa5419f33..6c3d2e4f4c 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -833,7 +833,8 @@ static int switch_branches(const struct checkout_opts *opts, int flag, writeout_error = 0; memset(&old, 0, sizeof(old)); old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag); - old.commit = lookup_commit_reference_gently(rev.hash, 1); + if (old.path) + old.commit = lookup_commit_reference_gently(rev.hash, 1); if (!(flag & REF_ISSYMREF)) old.path = NULL; |