From 45fb1698c1e24ad2fe35433f82668597aa315ab9 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 6 Jun 2023 22:40:13 -0700 Subject: [PATCH] Fix ub in `windowTitleHook` Called `updateTabBarRecursive` with null thisptr. --- src/Hy3Layout.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index b9a5492..780e0a7 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -601,10 +601,10 @@ void Hy3Node::updateTabBar() { void Hy3Node::updateTabBarRecursive() { auto* node = this; - while (node != nullptr) { + do { node->updateTabBar(); node = node->parent; - } + } while (node != nullptr); } void Hy3Node::updateDecos() { @@ -1675,6 +1675,8 @@ void Hy3Layout::windowTitleHook(void*, std::any data) { if (window == nullptr) return; auto* node = g_Hy3Layout->getNodeFromWindow(window); + // it is UB for `this` to be null + if (node == nullptr) return; node->updateTabBarRecursive(); }