Fix ub in windowTitleHook

Called `updateTabBarRecursive` with null thisptr.
This commit is contained in:
outfoxxed 2023-06-06 22:40:13 -07:00
parent 90f36e3b00
commit 45fb1698c1
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E

View file

@ -601,10 +601,10 @@ void Hy3Node::updateTabBar() {
void Hy3Node::updateTabBarRecursive() { void Hy3Node::updateTabBarRecursive() {
auto* node = this; auto* node = this;
while (node != nullptr) { do {
node->updateTabBar(); node->updateTabBar();
node = node->parent; node = node->parent;
} } while (node != nullptr);
} }
void Hy3Node::updateDecos() { void Hy3Node::updateDecos() {
@ -1675,6 +1675,8 @@ void Hy3Layout::windowTitleHook(void*, std::any data) {
if (window == nullptr) return; if (window == nullptr) return;
auto* node = g_Hy3Layout->getNodeFromWindow(window); auto* node = g_Hy3Layout->getNodeFromWindow(window);
// it is UB for `this` to be null
if (node == nullptr) return;
node->updateTabBarRecursive(); node->updateTabBarRecursive();
} }