diff --git a/source/common/objects/autosegs.h b/source/common/objects/autosegs.h index df996d2f0..91b404ad4 100644 --- a/source/common/objects/autosegs.h +++ b/source/common/objects/autosegs.h @@ -47,6 +47,12 @@ #define NO_SANITIZE #endif +#if defined _MSC_VER +#define NO_SANITIZE_M __declspec(no_sanitize_address) +#else +#define NO_SANITIZE_M +#endif + class FAutoSeg { const char *name; @@ -102,14 +108,14 @@ public: } template - void ForEach(Func func, std::enable_if_t> * = nullptr) + void NO_SANITIZE_M ForEach(Func func, std::enable_if_t> * = nullptr) { using CallableType = decltype(&Func::operator()); using ArgType = typename ArgumentType::Type; for (void **it = begin; it < end; ++it) { - if (*it) + if (intptr_t(it) > 0xffff && *it && intptr_t(*it) > 0xffff) { func(reinterpret_cast(*it)); } @@ -117,14 +123,14 @@ public: } template - void ForEach(Func func, std::enable_if_t> * = nullptr) + void NO_SANITIZE_M ForEach(Func func, std::enable_if_t> * = nullptr) { using CallableType = decltype(&Func::operator()); using ArgType = typename ArgumentType::Type; for (void **it = begin; it < end; ++it) { - if (*it) + if (intptr_t(it) > 0xffff && *it && intptr_t(*it) > 0xffff) { if (!func(reinterpret_cast(*it))) { diff --git a/source/common/objects/dobjtype.cpp b/source/common/objects/dobjtype.cpp index b74820ed4..250dccbdd 100644 --- a/source/common/objects/dobjtype.cpp +++ b/source/common/objects/dobjtype.cpp @@ -187,7 +187,7 @@ bool PClass::ReadAllFields(FSerializer &ar, void *addr) const // //========================================================================== -static int cregcmp (const void *a, const void *b) NO_SANITIZE +static NO_SANITIZE_M int cregcmp (const void *a, const void *b) NO_SANITIZE { const PClass *class1 = *(const PClass **)a; const PClass *class2 = *(const PClass **)b;