Skip to content

Commit

Permalink
revision.c: fix possible null pointer arithmetic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Naewe authored and Junio C Hamano committed Dec 7, 2015
1 parent 2435856 commit a2678df
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a2678df

Please sign in to comment.