Skip to content

Commit c26de08

Browse files
okodrongitster
authored andcommitted
commit: check result of resolve_ref_unsafe
Add check of the resolved HEAD reference while printing of a commit summary. resolve_ref_unsafe() may return NULL pointer if underlying calls of lstat() or open() fail in files_read_raw_ref(). Such situation can be caused by race: file becomes inaccessible to this moment. Signed-off-by: Andrey Okoshkin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c2224e commit c26de08

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/commit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,8 @@ static void print_summary(const char *prefix, const struct object_id *oid,
14831483
diff_setup_done(&rev.diffopt);
14841484

14851485
head = resolve_ref_unsafe("HEAD", 0, junk_oid.hash, NULL);
1486+
if (!head)
1487+
die_errno(_("unable to resolve HEAD after creating commit"));
14861488
if (!strcmp(head, "HEAD"))
14871489
head = _("detached HEAD");
14881490
else

0 commit comments

Comments
 (0)