From aa5e2b6a1928d1cf5629b6d2332e54b8660c72cf Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 23 Oct 2013 10:54:02 -0700 Subject: [PATCH] memset to 0 in VoxelNode to address potential memory corruption --- libraries/voxels/src/VoxelNode.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index b4fbce630f..72dbf07b62 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -441,6 +441,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; @@ -549,6 +550,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; @@ -871,6 +873,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; @@ -934,6 +938,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++) {