Mercurial > gemma
changeset 1788:00f34a00e6d5
Octree: Don't crash in horizontal traversal if the tree is empty.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 13 Jan 2019 13:47:08 +0100 |
parents | b0bf7533deec |
children | 4a7aa3f57efe |
files | pkg/octree/tree.go |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/octree/tree.go Sun Jan 13 13:09:50 2019 +0100 +++ b/pkg/octree/tree.go Sun Jan 13 13:47:08 2019 +0100 @@ -162,11 +162,13 @@ } else { max = mid } - stack = append(stack, - frame{ot.index[pos+0], min, max}, - frame{ot.index[pos+1], min, max}, - frame{ot.index[pos+2], min, max}, - frame{ot.index[pos+3], min, max}) + if pos+3 < int32(len(ot.index)) { + stack = append(stack, + frame{ot.index[pos+0], min, max}, + frame{ot.index[pos+1], min, max}, + frame{ot.index[pos+2], min, max}, + frame{ot.index[pos+3], min, max}) + } } else { // leaf pos = -pos - 1 n := ot.index[pos]