From 7f0b52de6fcddf98dc07ca3aa1c34e8b03e0416c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Wed, 18 Jan 2023 21:05:47 -0300 Subject: [PATCH 26/51] Add Missing Read Barriers to Map Get Functions --- src/common/scripting/core/maps.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/common/scripting/core/maps.cpp b/src/common/scripting/core/maps.cpp index bfc2b676d..b6ae925c6 100644 --- a/src/common/scripting/core/maps.cpp +++ b/src/common/scripting/core/maps.cpp @@ -118,8 +118,16 @@ template unsigned int MapCountUsed(M * self) template expand_types_vm MapGet(M * self,expand_types_vm key) { typename M::ValueType * v = self->CheckKey(key); - if (v) { - return *v; + if (v) + { + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(*v); + } + else + { + return *v; + } } else { @@ -149,7 +157,6 @@ template int MapCheckKey(M * self, expand_types_vmCheckKey(key) != nullptr; } - //========================================================================== // // MapInsert @@ -240,7 +247,14 @@ template void MapIteratorGetKeyString(I * self, FString &out) template expand_types_vm MapIteratorGetValue(I * self) { - return self->GetValue(); + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(self->GetValue()); + } + else + { + return self->GetValue(); + } } template void MapIteratorGetValueString(I * self, FString &out) -- 2.39.3