summaryrefslogtreecommitdiffstats
path: root/src/common/tree.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-05-24 01:28:40 +0200
committerGitHub <noreply@github.com>2021-05-24 01:28:40 +0200
commit3ead4a34940c952f980b1214968c09f59e04947f (patch)
treeaa559314c5332dc8dfc1e2303266592abc52ed48 /src/common/tree.h
parentMerge pull request #6248 from A-w-x/intelmesa (diff)
parenthle: kernel: service_thread: Take reference to KServerSession on service request. (diff)
downloadyuzu-3ead4a34940c952f980b1214968c09f59e04947f.tar
yuzu-3ead4a34940c952f980b1214968c09f59e04947f.tar.gz
yuzu-3ead4a34940c952f980b1214968c09f59e04947f.tar.bz2
yuzu-3ead4a34940c952f980b1214968c09f59e04947f.tar.lz
yuzu-3ead4a34940c952f980b1214968c09f59e04947f.tar.xz
yuzu-3ead4a34940c952f980b1214968c09f59e04947f.tar.zst
yuzu-3ead4a34940c952f980b1214968c09f59e04947f.zip
Diffstat (limited to 'src/common/tree.h')
-rw-r--r--src/common/tree.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/tree.h b/src/common/tree.h
index 9d2d0df4e..18faa4a48 100644
--- a/src/common/tree.h
+++ b/src/common/tree.h
@@ -43,6 +43,8 @@
* The maximum height of a red-black tree is 2lg (n+1).
*/
+#include "common/assert.h"
+
namespace Common {
template <typename T>
class RBHead {
@@ -325,6 +327,10 @@ void RB_REMOVE_COLOR(RBHead<Node>* head, Node* parent, Node* elm) {
while ((elm == nullptr || RB_IS_BLACK(elm)) && elm != head->Root() && parent != nullptr) {
if (RB_LEFT(parent) == elm) {
tmp = RB_RIGHT(parent);
+ if (!tmp) {
+ ASSERT_MSG(false, "tmp is invalid!");
+ break;
+ }
if (RB_IS_RED(tmp)) {
RB_SET_BLACKRED(tmp, parent);
RB_ROTATE_LEFT(head, parent, tmp);
@@ -366,6 +372,11 @@ void RB_REMOVE_COLOR(RBHead<Node>* head, Node* parent, Node* elm) {
tmp = RB_LEFT(parent);
}
+ if (!tmp) {
+ ASSERT_MSG(false, "tmp is invalid!");
+ break;
+ }
+
if ((RB_LEFT(tmp) == nullptr || RB_IS_BLACK(RB_LEFT(tmp))) &&
(RB_RIGHT(tmp) == nullptr || RB_IS_BLACK(RB_RIGHT(tmp)))) {
RB_SET_COLOR(tmp, EntryColor::Red);