summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Naewe <stefan.naewe@gmail.com>2015-12-05 16:27:24 +0100
committerJunio C Hamano <gitster@pobox.com>2015-12-07 12:32:02 -0800
commita2678df335f3404bc5d96683fa36b8cfab7946b0 (patch)
treebc5ec704370e60f8db15ad3f1dd409906bf5e7e9
parent24358560c3c0ab51c9ef8178d99f46711716f6c0 (diff)
downloadgit-a2678df335f3404bc5d96683fa36b8cfab7946b0.tar.gz
revision.c: fix possible null pointer arithmeticsn/null-pointer-arith-in-mark-tree-uninteresting
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>
-rw-r--r--revision.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/revision.c b/revision.c
index 9b9d77dc43..7f4acad456 100644
--- a/revision.c
+++ b/revision.c
@@ -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;