revision.c: fix possible null pointer arithmetic
authorStefan Naewe <stefan.naewe@gmail.com>
Sat, 5 Dec 2015 15:27:24 +0000 (16:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Dec 2015 20:32:02 +0000 (12:32 -0800)
mark_tree_uninteresting() dereferences a tree pointer before
checking if the pointer is valid. Fix that by doing the check first.

Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c
index 9b9d77dc439d6a6c8e25c58454833804116db14a..7f4acad456a3f5adbf2a5828718ab4488d947388 100644 (file)
@@ -131,10 +131,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;