summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-12-11 10:41:01 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-12-11 10:41:01 -0800
commit782ca8c44e176e8a00c2c824a98dbe6274167639 (patch)
treee584f823e702c36b82f207d4a726cfb192903b8b
parentMerge branch 'sb/doc-submodule-sync-recursive' (diff)
parentrevision.c: fix possible null pointer arithmetic (diff)
downloadtgif-782ca8c44e176e8a00c2c824a98dbe6274167639.tar.xz
Merge branch 'sn/null-pointer-arith-in-mark-tree-uninteresting'
mark_tree_uninteresting() has code to handle the case where it gets passed a NULL pointer in its 'tree' parameter, but the function had 'object = &tree->object' assignment before checking if tree is NULL. This gives a compiler an excuse to declare that tree will never be NULL and apply a wrong optimization. Avoid it. * sn/null-pointer-arith-in-mark-tree-uninteresting: revision.c: fix possible null pointer arithmetic
-rw-r--r--revision.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/revision.c b/revision.c
index 2a9463bd67..9404a05eeb 100644
--- a/revision.c
+++ b/revision.c
@@ -135,10 +135,12 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
void mark_tree_uninteresting(struct tree *tree)
{
- struct object *obj = &tree->object;
+ struct object *obj;
if (!tree)
return;
+
+ obj = &tree->object;
if (obj->flags & UNINTERESTING)
return;
obj->flags |= UNINTERESTING;