summaryrefslogtreecommitdiff
path: root/list-objects.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2019-04-10 02:13:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-10 03:59:39 (GMT)
commit23c204455bf2198806e8c7b0cd86b20a50a379d0 (patch)
tree53bcb4f59c3793bd98ecbe24206121a3b6561f10 /list-objects.c
parent0616617c7e1470e11c10dcb0fb72100ce3b15ec4 (diff)
downloadgit-23c204455bf2198806e8c7b0cd86b20a50a379d0.zip
git-23c204455bf2198806e8c7b0cd86b20a50a379d0.tar.gz
git-23c204455bf2198806e8c7b0cd86b20a50a379d0.tar.bz2
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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects.c')
-rw-r--r--list-objects.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/list-objects.c b/list-objects.c
index dc77361..ea04bbd 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);
}