Merge branch 'sn/null-pointer-arith-in-mark-tree-uninteresting' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 11 Dec 2015 19:14:38 +0000 (11:14 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 11 Dec 2015 19:14:38 +0000 (11:14 -0800)
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

revision.c
index 351fb5b9f12cf7dffe14f7aca49dad1576248696..f6caef067220e9ecae7cc1b21b7b01380544c066 100644 (file)
@@ -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;