diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index 609d11c1e9..8e225dc2ed 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -510,6 +510,7 @@ void VoxelNode::storeTwoChildren(VoxelNode* childOne, VoxelNode* childTwo) { const int newChildCount = 2; _externalChildrenMemoryUsage += newChildCount * sizeof(VoxelNode*); _children.external = new VoxelNode*[newChildCount]; + memset(_children.external, 0, sizeof(VoxelNode*) * newChildCount); } _children.external[0] = childOne; _children.external[1] = childTwo; @@ -620,6 +621,7 @@ void VoxelNode::storeThreeChildren(VoxelNode* childOne, VoxelNode* childTwo, Vox const int newChildCount = 3; _externalChildrenMemoryUsage += newChildCount * sizeof(VoxelNode*); _children.external = new VoxelNode*[newChildCount]; + memset(_children.external, 0, sizeof(VoxelNode*) * newChildCount); } _children.external[0] = childOne; _children.external[1] = childTwo; @@ -1004,6 +1006,8 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) { _childrenExternal = true; const int newChildCount = 4; _children.external = new VoxelNode*[newChildCount]; + memset(_children.external, 0, sizeof(VoxelNode*) * newChildCount); + _externalChildrenMemoryUsage += newChildCount * sizeof(VoxelNode*); _children.external[0] = childOne; @@ -1072,6 +1076,7 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) { // 4 or more children, one item being added, we know we're stored externally, we just figure out where to insert // this child pointer into our external list VoxelNode** newExternalList = new VoxelNode*[newChildCount]; + memset(newExternalList, 0, sizeof(VoxelNode*) * newChildCount); int copiedCount = 0; for (int ordinal = 1; ordinal <= newChildCount; ordinal++) {