diff --git a/octomap/include/octomap/OcTreeBaseImpl.hxx b/octomap/include/octomap/OcTreeBaseImpl.hxx index dd7c2b21..a080b1cd 100644 --- a/octomap/include/octomap/OcTreeBaseImpl.hxx +++ b/octomap/include/octomap/OcTreeBaseImpl.hxx @@ -705,9 +705,13 @@ namespace octomap { // TODO delete check depth, what happens to inner nodes with children? this->deleteNodeChild(node, pos); - if (!nodeHasChildren(node)) + if (!nodeHasChildren(node)){ + if (node->children != NULL){ + delete[] node->children; + node->children = NULL; + } return true; - else{ + } else { node->updateOccupancyChildren(); // TODO: occupancy? } }