Browse Source

tree-diff: don't access hash of NULL object_id pointer

The object_id pointers can be NULL for invalid entries.  Don't try to
dereference them and pass NULL along to fill_tree_descriptor() instead,
which handles them just fine.

Found with Clang's UBSan.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
René Scharfe 7 years ago committed by Junio C Hamano
parent
commit
fb04dced9c
  1. 5
      tree-diff.c

5
tree-diff.c

@ -422,8 +422,9 @@ static struct combine_diff_path *ll_diff_tree_paths(
* diff_tree_oid(parent, commit) ) * diff_tree_oid(parent, commit) )
*/ */
for (i = 0; i < nparent; ++i) for (i = 0; i < nparent; ++i)
tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash); tptree[i] = fill_tree_descriptor(&tp[i],
ttree = fill_tree_descriptor(&t, oid->hash); parents_oid[i] ? parents_oid[i]->hash : NULL);
ttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);


/* Enable recursion indefinitely */ /* Enable recursion indefinitely */
opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE); opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);

Loading…
Cancel
Save