summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-07-15 17:18:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-17 21:49:36 (GMT)
commitfb04dced9c6510176f06953d2cd6a239703401f1 (patch)
treef76301d811e1c428a8a84336184441edda5fc9f9
parent94e327e973d320abf91c22307b87292911643c3b (diff)
downloadgit-fb04dced9c6510176f06953d2cd6a239703401f1.zip
git-fb04dced9c6510176f06953d2cd6a239703401f1.tar.gz
git-fb04dced9c6510176f06953d2cd6a239703401f1.tar.bz2
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>
-rw-r--r--tree-diff.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tree-diff.c b/tree-diff.c
index 467e381..7f7ddda 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -422,8 +422,9 @@ static struct combine_diff_path *ll_diff_tree_paths(
* diff_tree_oid(parent, commit) )
*/
for (i = 0; i < nparent; ++i)
- tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash);
- ttree = fill_tree_descriptor(&t, oid->hash);
+ tptree[i] = fill_tree_descriptor(&tp[i],
+ parents_oid[i] ? parents_oid[i]->hash : NULL);
+ ttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);
/* Enable recursion indefinitely */
opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);