Skip to content

Commit 753ecf4

Browse files
ysinghcgitster
authored andcommitted
path-walk: fix NULL pointer dereference in error message
When lookup_tree() or lookup_blob() cannot find a tree entry's object, 'o' is set to NULL via: o = child ? &child->object : NULL; The subsequent null-check catches this correctly, but then dereferences 'o' to format the error message: error(_("failed to find object %s"), oid_to_hex(&o->oid)); This causes a segfault instead of the intended diagnostic output. Fix this by using &entry.oid instead. 'entry' is the struct name_entry populated by tree_entry() on each loop iteration and holds the OID of the failing lookup -- which is exactly what the error should report. This crash is reachable via git-backfill(1) when a tree entry's object is absent from the local object database. Signed-off-by: Yuvraj Singh Chauhan <ysinghcin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9a2fb14 commit 753ecf4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

path-walk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int add_tree_entries(struct path_walk_context *ctx,
171171

172172
if (!o) {
173173
error(_("failed to find object %s"),
174-
oid_to_hex(&o->oid));
174+
oid_to_hex(&entry.oid));
175175
return -1;
176176
}
177177

0 commit comments

Comments
 (0)