Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/coreclr/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3304,8 +3304,9 @@ HRESULT CordbReJitILCode::Init(DacSharedReJitInfo* pSharedReJitInfo)
m_cbLocalIL = ilCodeSize;
IfFailRet(GetProcess()->SafeReadBuffer(m_codeRegionInfo, m_pLocalIL, FALSE /*throwOnError*/));

// Check if this il code has exception clauses
if ((pMethodTinyHeader->Flags_CodeSize & CorILMethod_MoreSects) == 0)
// Check if this il code has exception clauses. A tiny header has no flags for extra sections:
// its upper bits are the code size, so CorILMethod_MoreSects only applies to a fat header.
if (isTinyHeader || (pMethodTinyHeader->Flags_CodeSize & CorILMethod_MoreSects) == 0)
{
return S_OK; // no EH, done initing
}
Expand Down Expand Up @@ -3358,14 +3359,16 @@ HRESULT CordbReJitILCode::Init(DacSharedReJitInfo* pSharedReJitInfo)
// Read in the section header to see how many small clauses there are
IMAGE_COR_ILMETHOD_SECT_SMALL sectionHeader = { 0 };
IfFailRet(GetProcess()->SafeReadStruct(ehClauseHeader, &sectionHeader));
ULONG32 m_cClauses = (sectionHeader.DataSize - 4) / sizeof(IMAGE_COR_ILMETHOD_SECT_SMALL);
// The small clauses start after the 2 byte section header and a 2 byte Reserved field
const ULONG32 cbSmallSectionHeader = offsetof(IMAGE_COR_ILMETHOD_SECT_EH_SMALL, Clauses);
m_cClauses = (sectionHeader.DataSize - cbSmallSectionHeader) / sizeof(IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL);
if (m_cClauses > 10000) // sanity check the data before allocating
{
return CORDBG_E_TARGET_INCONSISTENT;
}

// Read in the clauses
TargetBuffer buffer(ehClauseHeader + sizeof(IMAGE_COR_ILMETHOD_SECT_SMALL), m_cClauses*sizeof(IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL));
TargetBuffer buffer(ehClauseHeader + cbSmallSectionHeader, m_cClauses*sizeof(IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL));
NewArrayHolder<IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL> pClauses = new (nothrow)IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL[m_cClauses];
if (pClauses == NULL)
return E_OUTOFMEMORY;
Expand Down
Loading