Skip to content

Commit 57e0ef0

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 79e913c commit 57e0ef0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ static void am_abort(struct am_state *state)
21572157
am_rerere_clear();
21582158

21592159
curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
2160-
has_curr_head = !is_null_oid(&curr_head);
2160+
has_curr_head = curr_branch && !is_null_oid(&curr_head);
21612161
if (!has_curr_head)
21622162
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
21632163

0 commit comments

Comments
 (0)