diff --git a/src/coreclr/md/runtime/metamodel.cpp b/src/coreclr/md/runtime/metamodel.cpp index 14654f7657b95..7a27c4e85e5ba 100644 --- a/src/coreclr/md/runtime/metamodel.cpp +++ b/src/coreclr/md/runtime/metamodel.cpp @@ -717,7 +717,17 @@ CMiniMdBase::InitColsForTable( // should we write the data into the structure { const CMiniTableDef *pTemplate; // Template table definition. - CMiniColDef pCols[9]; // The col defs to init. + const int MaxCols = 9; + typedef uint32_t markword_t; + BYTE tempCols[sizeof(markword_t) + MaxCols * sizeof(CMiniColDef)]; // keep aligned + + _ASSERTE(MaxCols >= pTable->m_cCols); + // + // Mark the array of columns as not allocated (eg, not ALLOCATED_MEMORY_MARKER) + // for SetNewColumnDefinition call + // + memset(tempCols, 0, sizeof(markword_t)); + CMiniColDef *pCols = BYTEARRAY_TO_COLDES(tempCols + sizeof(markword_t) - 1); // The col defs to init. BYTE iOffset; // Running size of a record. BYTE iSize; // Size of a field. HRESULT hr = S_OK; @@ -726,10 +736,8 @@ CMiniMdBase::InitColsForTable( _ASSERTE(ARRAY_SIZE(pCols) >= pTable->m_cCols); bExtra = 0;//@FUTURE: save in schema header. until then use 0. - iOffset = 0; - - pTemplate = GetTableDefTemplate(ixTbl); + pTemplate = GetTableDefTemplate(ixTbl); PREFIX_ASSUME(pTemplate->m_pColDefs != NULL);