Skip to content

Commit

Permalink
Merge branch 'sn/null-pointer-arith-in-mark-tree-uninteresting' into …
Browse files Browse the repository at this point in the history
…maint

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
  • Loading branch information
Junio C Hamano committed Dec 11, 2015
2 parents abca668 + a2678df commit 58e3dd2
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 @@ -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;
Expand Down

0 comments on commit 58e3dd2

Please sign in to comment.