Skip to content

Commit

Permalink
Protect Child from returning Node of nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
arl committed Oct 21, 2016
1 parent 8c30015 commit 267a755
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions basicnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func (n *basicNode) Parent() Node {

// Child returns current node child at specified quadrant.
func (n *basicNode) Child(q Quadrant) Node {
if n.c[q] == nil {
return nil
}
return n.c[q]
}

Expand Down
3 changes: 3 additions & 0 deletions cnnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func (n *cnNode) Parent() Node {

// Child returns current node child at specified quadrant.
func (n *cnNode) Child(q Quadrant) Node {
if n.c[q] == nil {
return nil
}
return n.c[q]
}

Expand Down

0 comments on commit 267a755

Please sign in to comment.