added guard to protect against external child access

This commit is contained in:
ZappoMan 2013-10-25 14:22:56 -07:00
parent dcccfb7ef0
commit b8a87294e6

View file

@ -409,7 +409,12 @@ VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const {
for (int ordinal = 1; ordinal <= childCount; ordinal++) {
int index = getNthBit(_childBitmask, ordinal);
if (index == childIndex) {
result = _children.external[ordinal-1];
int externalIndex = ordinal-1;
if (externalIndex < childCount && externalIndex >= 0) {
result = _children.external[externalIndex];
} else {
qDebug("getChildAtIndex() attempt to access external client out of bounds externalIndex=%d <<<<<<<<<< WARNING!!! \n",externalIndex);
}
break;
}
}