diff options
author | Omair Majid <omajid@redhat.com> | 2019-04-16 01:12:39 -0400 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2019-04-15 22:12:39 -0700 |
commit | 0f838a7c22c6e19748582ced5e03a8e273f63062 (patch) | |
tree | ae2096443906a638c83c9753cf2577383f52fc8b /src/vm/methodtable.cpp | |
parent | f6938e2b5497cce88ab7b3643ab5f3174d8bb3e7 (diff) | |
download | coreclr-0f838a7c22c6e19748582ced5e03a8e273f63062.tar.gz coreclr-0f838a7c22c6e19748582ced5e03a8e273f63062.tar.bz2 coreclr-0f838a7c22c6e19748582ced5e03a8e273f63062.zip |
Use NewArrayHolder for array types (#24017)
This touches all the code outside of src/debug/.
Using a NewHolder with array types means that when the holder is ready
to release the memory, it ends up invoking `delete` (instead of
`delete[]`) on that array. This is an undefined behaviour.
Use NewArrayHolder instead to fix this.
Diffstat (limited to 'src/vm/methodtable.cpp')
-rw-r--r-- | src/vm/methodtable.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp index 34381fa2aa..43ba55b4e5 100644 --- a/src/vm/methodtable.cpp +++ b/src/vm/methodtable.cpp @@ -8976,7 +8976,7 @@ void MethodTable::CheckInitMethodDataCache() if (s_pMethodDataCache == NULL) { UINT32 cb = MethodDataCache::GetObjectSize(8); - NewHolder<BYTE> hb(new BYTE[cb]); + NewArrayHolder<BYTE> hb(new BYTE[cb]); MethodDataCache *pCache = new (hb.GetValue()) MethodDataCache(8); if (InterlockedCompareExchangeT( &s_pMethodDataCache, pCache, NULL) == NULL) @@ -9085,7 +9085,7 @@ MethodTable::GetMethodDataHelper( MethodDataWrapper hImpl(GetMethodData(pMTImpl, FALSE)); UINT32 cb = MethodDataInterfaceImpl::GetObjectSize(pMTDecl); - NewHolder<BYTE> pb(new BYTE[cb]); + NewArrayHolder<BYTE> pb(new BYTE[cb]); MethodDataInterfaceImpl * pData = new (pb.GetValue()) MethodDataInterfaceImpl(rgDeclTypeIDs, cDeclTypeIDs, hDecl, hImpl); pb.SuppressRelease(); @@ -9128,7 +9128,7 @@ MethodTable::MethodData *MethodTable::GetMethodDataHelper(MethodTable *pMTDecl, } else { UINT32 cb = MethodDataObject::GetObjectSize(pMTDecl); - NewHolder<BYTE> pb(new BYTE[cb]); + NewArrayHolder<BYTE> pb(new BYTE[cb]); MethodDataHolder h(FindParentMethodDataHelper(pMTDecl)); pData = new (pb.GetValue()) MethodDataObject(pMTDecl, h.GetValue()); pb.SuppressRelease(); |