From 23c204455bf2198806e8c7b0cd86b20a50a379d0 Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Tue, 9 Apr 2019 19:13:17 -0700 Subject: list-objects.c: handle unexpected non-blob entries Fix one of the cases described in the previous commit where a tree-entry that is promised to a blob is in fact a non-blob. When 'lookup_blob()' returns NULL, it is because Git has cached the requested object as a non-blob. In this case, prevent a SIGSEGV by 'die()'-ing immediately before attempting to dereference the result. Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- list-objects.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'list-objects.c') diff --git a/list-objects.c b/list-objects.c index dc77361e11..ea04bbdee6 100644 --- a/list-objects.c +++ b/list-objects.c @@ -133,6 +133,11 @@ static void process_tree_contents(struct traversal_context *ctx, base, entry.path); else { struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid); + if (!b) { + die(_("entry '%s' in tree %s has blob mode, " + "but is not a blob"), + entry.path, oid_to_hex(&tree->object.oid)); + } b->object.flags |= NOT_USER_GIVEN; process_blob(ctx, b, base, entry.path); } -- cgit 1.2.3-korg