Ensure swallowGroup does not swallow the root node

Fixes a segfault
This commit is contained in:
outfoxxed 2023-04-19 19:53:50 -07:00
parent 9082d9259f
commit 1e4681bfeb
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E

View file

@ -198,8 +198,12 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
}
bool swallowGroup(Hy3Node* into) {
if (into == nullptr || into->data.type != Hy3NodeData::Group) return false;
if (into->data.as_group.children.size() != 1) return false;
if (into == nullptr
|| into->parent == nullptr
|| into->data.type != Hy3NodeData::Group
|| into->data.as_group.children.size() != 1)
return false;
auto* child = into->data.as_group.children.front();
Debug::log(LOG, "Swallowing %p into %p", child, into);