45fb1698c1e24ad2fe35433f82668597aa315ab9

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

Message

Fix ub in `windowTitleHook`

Called `updateTabBarRecursive` with null thisptr.

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index b9a5492333298282e56c1115d702a7ea02b62e0d..780e0a722a68697b5afef1f3e9d3206635c4d978 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -601,10 +601,10 @@ void Hy3Node::updateTabBar() {
 6 void Hy3Node::updateTabBarRecursive() {
 7 	auto* node = this;
 8 
 9-	while (node != nullptr) {
10+	do {
11 		node->updateTabBar();
12 		node = node->parent;
13-	}
14+	} while (node != nullptr);
15 }
16 
17 void Hy3Node::updateDecos() {
18@@ -1675,6 +1675,8 @@ void Hy3Layout::windowTitleHook(void*, std::any data) {
19 	if (window == nullptr) return;
20 	auto* node = g_Hy3Layout->getNodeFromWindow(window);
21 
22+	// it is UB for `this` to be null
23+	if (node == nullptr) return;
24 	node->updateTabBarRecursive();
25 }
26