Skip to content

Commit

Permalink
Fix ilasm crash on empty local variable name (#46080)
Browse files Browse the repository at this point in the history
Fixes #45908
  • Loading branch information
jkotas authored Dec 15, 2020
1 parent 87ff54b commit 7ae298e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/coreclr/ilasm/portable_pdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,16 @@ BOOL PortablePdbWriter::_DefineLocalScope(mdMethodDef methodDefToken, Scope* cur

while (pLocalVar != NULL)
{
mdLocalVariable locVarToken = mdLocalScopeNil;
USHORT attribute = 0; // TODO: not supported for now
USHORT index = pLocalVar->dwAttr & 0xffff; // slot
if (FAILED(m_pdbEmitter->DefineLocalVariable(attribute, index, (char*)pLocalVar->szName, &locVarToken))) goto exit;
if (pLocalVar->szName != NULL)
{
mdLocalVariable locVarToken = mdLocalScopeNil;
USHORT attribute = 0; // TODO: not supported for now
USHORT index = pLocalVar->dwAttr & 0xffff; // slot
if (FAILED(m_pdbEmitter->DefineLocalVariable(attribute, index, (char*)pLocalVar->szName, &locVarToken))) goto exit;

if (firstLocVarToken == mdLocalScopeNil)
firstLocVarToken = locVarToken;
if (firstLocVarToken == mdLocalScopeNil)
firstLocVarToken = locVarToken;
}

pLocalVar = pLocalVar->pNext;
}
Expand Down

0 comments on commit 7ae298e

Please sign in to comment.