Skip to content

Commit 38b8e81

Browse files
authored
Use unsized delete when we calculate size dynamically in a custom new overload (#119112)
1 parent ed57bae commit 38b8e81

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/coreclr/vm/crossloaderallocatorhash.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ class CrossLoaderAllocatorHash
200200
static void* operator new(size_t baseSize, CountWrapper capacity);
201201

202202
public:
203+
static void operator delete(void* ptr)
204+
{
205+
::operator delete(ptr);
206+
}
207+
203208
static KeyValueStore *Create(TCount capacity, const TKey &key);
204209

205210
TCount GetCapacity() const { return _capacity; }

src/coreclr/vm/methodtable.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,6 +3122,10 @@ public :
31223122
static void HolderRelease(MethodData *pEntry)
31233123
{ WRAPPER_NO_CONTRACT; if (pEntry != NULL) pEntry->Release(); }
31243124

3125+
static void operator delete(void* ptr)
3126+
{
3127+
::operator delete(ptr);
3128+
}
31253129
protected:
31263130
ULONG m_cRef;
31273131
MethodTable *const m_pImplMT;
@@ -3357,6 +3361,12 @@ public :
33573361
_ASSERTE(size <= GetObjectSize(targetMT.pMT, computeOptions));
33583362
return ::operator new(GetObjectSize(targetMT.pMT, computeOptions));
33593363
}
3364+
3365+
static void operator delete(void* ptr)
3366+
{
3367+
::operator delete(ptr);
3368+
}
3369+
33603370
static void* operator new(size_t size) = delete;
33613371
}; // class MethodDataObject
33623372

src/coreclr/vm/virtualcallstub.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class VirtualCallStubManager : public StubManager
321321
static BOOL isStubStatic(PCODE addr)
322322
{
323323
WRAPPER_NO_CONTRACT;
324-
324+
325325
#ifdef FEATURE_CACHED_INTERFACE_DISPATCH
326326
if (isCachedInterfaceDispatchStub(addr))
327327
return TRUE;
@@ -1550,6 +1550,11 @@ class FastTable
15501550
{
15511551
return ::operator new(baseSize + (numCallStubs + CALL_STUB_FIRST_INDEX) * sizeof(size_t));
15521552
}
1553+
public:
1554+
static void operator delete(void* ptr)
1555+
{
1556+
::operator delete(ptr);
1557+
}
15531558
};
15541559
#ifdef _MSC_VER
15551560
#pragma warning(pop)

0 commit comments

Comments
 (0)