From 2190419b83c7c587858dbbc56fc9862a29b4d7d7 Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:09:41 +0200 Subject: [PATCH] Util/fixed_typemap.hpp: set unitialiazed data to trap values --- rpcs3/util/auto_typemap.hpp | 5 ++++- rpcs3/util/fixed_typemap.hpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/auto_typemap.hpp b/rpcs3/util/auto_typemap.hpp index fba32e74a7..58f5b7d257 100644 --- a/rpcs3/util/auto_typemap.hpp +++ b/rpcs3/util/auto_typemap.hpp @@ -44,6 +44,7 @@ namespace stx static void call_dtor(void* ptr) noexcept { std::launder(static_cast(ptr))->~T(); + std::memset(ptr, 0xCC, sizeof(T)); // Set to trap values } template @@ -93,9 +94,11 @@ namespace stx { ensure(Size >= stx::typelist().size()); ensure(Align >= stx::typelist().align()); - m_data[0] = 0; } + // Set to trap values + std::memset(Size == 0 ? m_list : m_data, 0xCC, stx::typelist().size()); + for (const auto& type : stx::typelist()) { const u32 id = type.index(); diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 0679de49c2..b8844e22a6 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -122,6 +122,7 @@ namespace stx static void call_dtor(void* ptr) noexcept { std::launder(static_cast(ptr))->~T(); + std::memset(ptr, 0xCC, sizeof(T)); // Set to trap values } template @@ -219,9 +220,11 @@ namespace stx { ensure(Size >= stx::typelist().size()); ensure(Align >= stx::typelist().align()); - m_data[0] = 0; } + // Set to trap values + std::memset(Size == 0 ? m_list : m_data, 0xCC, stx::typelist().size()); + *m_order++ = nullptr; *m_info++ = nullptr; }