summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Okoshkin <a.okoshkin@samsung.com>2017-10-20 11:03:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-21 12:23:44 (GMT)
commitc26de08370ad5d927d93dbe6fb46103caabb889c (patch)
tree3b500a2666d4989d0a46a9bbfeb18974878ac695
parent4c2224e83951a685185bb8c1f83b28e22fee0e27 (diff)
downloadgit-c26de08370ad5d927d93dbe6fb46103caabb889c.zip
git-c26de08370ad5d927d93dbe6fb46103caabb889c.tar.gz
git-c26de08370ad5d927d93dbe6fb46103caabb889c.tar.bz2
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 <a.okoshkin@samsung.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/commit.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 1a0da71..b528290 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1483,6 +1483,8 @@ static void print_summary(const char *prefix, const struct object_id *oid,
diff_setup_done(&rev.diffopt);
head = resolve_ref_unsafe("HEAD", 0, junk_oid.hash, NULL);
+ if (!head)
+ die_errno(_("unable to resolve HEAD after creating commit"));
if (!strcmp(head, "HEAD"))
head = _("detached HEAD");
else