From 2a2cb5c8a0ee1a1c93c64810ce664017b8b53c91 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 14 May 2023 22:44:19 -0700 Subject: [PATCH] Fix UAF in removeFromParentRecursive --- src/Hy3Layout.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 95995b2..5259e7f 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -332,6 +332,7 @@ Hy3Node* Hy3Node::removeFromParentRecursive() { group.lastFocusedChild = group.children.front(); } + auto child_size_ratio = child->size_ratio; if (child != this) { parent->layout->nodes.remove(*child); } else { @@ -344,7 +345,7 @@ Hy3Node* Hy3Node::removeFromParentRecursive() { child_count -= 1; } - auto splitmod = -((1.0 - child->size_ratio) / child_count); + auto splitmod = -((1.0 - child_size_ratio) / child_count); for (auto* child: group.children) { child->size_ratio += splitmod;