Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-05-06 20:13:56 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-08 05:12:42 +0300
commit57e0ef0e0e90c4cb72c35db874fc3d035b88ce4d (patch)
tree5d18c963265442be4c33623c6cafdd9b9013fd56 /builtin/am.c
parent79e913c24aa37d0ede9ed9e8962a19634ae5129a (diff)
am: check return value of resolve_refdup before using hash
If resolve_refdup() fails it returns NULL and possibly leaves its hash output parameter untouched. Make sure to use it only if the function succeeded, in order to avoid accessing uninitialized memory. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
-rw-r--r--builtin/am.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 31fb60578f..695968622a 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2157,7 +2157,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);