mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
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
This commit is contained in:
commit
e40c0f4288
|
@ -2150,7 +2150,7 @@ static void am_abort(struct am_state *state)
|
|||
am_rerere_clear();
|
||||
|
||||
curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
|
||||
has_curr_head = !is_null_oid(&curr_head);
|
||||
has_curr_head = curr_branch && !is_null_oid(&curr_head);
|
||||
if (!has_curr_head)
|
||||
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
|
||||
|
||||
|
|
|
@ -833,6 +833,7 @@ 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);
|
||||
if (old.path)
|
||||
old.commit = lookup_commit_reference_gently(rev.hash, 1);
|
||||
if (!(flag & REF_ISSYMREF))
|
||||
old.path = NULL;
|
||||
|
|
Loading…
Reference in a new issue