From a397a93c25434676e3c232b119111e776425a08c 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] Add Missing Read Barriers to Map Get Functions --- src/common/scripting/core/maps.cpp | 39 ++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/common/scripting/core/maps.cpp b/src/common/scripting/core/maps.cpp index e4ef24a5dc..07522e2e1e 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 { @@ -148,7 +156,14 @@ template expand_types_vm MapGetIfExists(M * s { typename M::ValueType * v = self->CheckKey(key); if (v) { - return *v; + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(*v); + } + else + { + return *v; + } } else { @@ -177,7 +192,14 @@ template expand_types_vm MapCheckValue(M * se { typename M::ValueType * v = self->CheckKey(key); if ((*exists = !!v)) { - return *v; + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(*v); + } + else + { + return *v; + } } else { @@ -288,7 +310,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)