FIX: fixed segmentation fault when deleting all children

This commit is contained in:
Dominik Meyer 2024-01-29 11:43:58 +01:00
parent 1cbb6c108e
commit 86bb4baaf8
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97
1 changed files with 4 additions and 0 deletions

View File

@ -18,6 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <iostream>
#include <iomanip>
#include <Tree/tree.hpp>
#include <iterator>
#include <memory>
std::list<std::shared_ptr<Tree::BaseNode>>::const_iterator Tree::BaseNode::getChildIterator(const std::shared_ptr<const Tree::BaseNode> child) const
@ -132,7 +133,10 @@ void Tree::BaseNode::deleteChildren()
{
if ((*it) != nullptr )
{
auto prev = std::prev(it);
deleteChild((*it));
it=prev;
}
}