1e4681bfebe7541567649c15158aa6875d260400

Author
outfoxxed <outfoxxed@outfoxxed.me>
Committer
outfoxxed <outfoxxed@outfoxxed.me>
Date

Message

Ensure swallowGroup does not swallow the root node

Fixes a segfault

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index da403101898ca48ed780bc60a8271187ab7da57a..bd476eaa743005e26013e19ec41b08d6d7e5526c 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -198,8 +198,12 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 6 }
 7 
 8 bool swallowGroup(Hy3Node* into) {
 9-	if (into == nullptr || into->data.type != Hy3NodeData::Group) return false;
10-	if (into->data.as_group.children.size() != 1) return false;
11+	if (into == nullptr
12+			|| into->parent == nullptr
13+			|| into->data.type != Hy3NodeData::Group
14+			|| into->data.as_group.children.size() != 1)
15+		return false;
16+
17 	auto* child = into->data.as_group.children.front();
18 
19 	Debug::log(LOG, "Swallowing %p into %p", child, into);