From 94211fb36f51bedd18e37d874374b1bdd254e31c Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 17 Jul 2026 00:43:40 +0200 Subject: [PATCH] Fix address sanitizer issues This fixes two issues discovered by the address sanitizer: * ::delete called on base class pointer is not correct, as the :: tells the compiler to use sized delete and since that one gets size of the base class and not the real type, the sanitizer complains. It is currently benign, as the sized delete ignores the size. * Deletion of an array via non-array delete operator (and using a wrong type) --- src/coreclr/utilcode/ex.cpp | 5 ----- src/coreclr/vm/ceeload.cpp | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/coreclr/utilcode/ex.cpp b/src/coreclr/utilcode/ex.cpp index e4036d236b6a5e..d93e6c6ce57a09 100644 --- a/src/coreclr/utilcode/ex.cpp +++ b/src/coreclr/utilcode/ex.cpp @@ -96,12 +96,7 @@ void Exception::Delete(Exception* pvMemory) return; } -#ifdef DACCESS_COMPILE delete pvMemory; -#else - ::delete pvMemory; -#endif - } void Exception::GetMessage(SString &result) diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 268277a34a4679..855f6df4bb225d 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -3896,7 +3896,7 @@ void ReflectionModule::Destruct() Module::Destruct(); - delete (uint32_t*)m_pDynamicMetadata; + delete[] (uint8_t*)m_pDynamicMetadata; m_pDynamicMetadata = (TADDR)NULL; m_CrstLeafLock.Destroy(); @@ -4033,7 +4033,7 @@ void ReflectionModule::CaptureModuleMetaDataToMemory() { CrstHolder ch(&m_CrstLeafLock); - delete (uint32_t*)m_pDynamicMetadata; + delete[] (uint8_t*)m_pDynamicMetadata; m_pDynamicMetadata = (TADDR)pBuffer.Extract(); }