From 3f5a80d692966fec367aad950b5e6304a9a08be8 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 23 Dec 2023 21:32:12 +0100 Subject: [PATCH] Typemap: Set init to false after each individual destructor --- rpcs3/util/auto_typemap.hpp | 7 ++++++- rpcs3/util/fixed_typemap.hpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/auto_typemap.hpp b/rpcs3/util/auto_typemap.hpp index 58f5b7d257..fb25e7b8ef 100644 --- a/rpcs3/util/auto_typemap.hpp +++ b/rpcs3/util/auto_typemap.hpp @@ -135,7 +135,12 @@ namespace stx // Destroy objects in reverse order for (; _max; _max--) { - (*--m_info)->destroy(*--m_order); + auto* info = *--m_info; + const u32 type_index = static_cast*>(info)->index(); + info->destroy(*--m_order); + + // Set init to false. We don't want other fxo to use this fxo in their destructor. + m_init[type_index] = false; } // Pointers should be restored to their positions diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 4df9c57891..6c42f3ad64 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -313,7 +313,12 @@ namespace stx // Destroy objects in reverse order for (; _max; _max--) { - (*--m_info)->destroy(*--m_order); + auto* info = *--m_info; + const u32 type_index = static_cast*>(info)->index(); + info->destroy(*--m_order); + + // Set init to false. We don't want other fxo to use this fxo in their destructor. + m_init[type_index] = false; } // Pointers should be restored to their positions