Fix memory corruption issue

This commit is contained in:
Hackerpilot 2014-05-27 11:09:18 -07:00
parent 629c8a7959
commit 7ed6d94a58
1 changed files with 5 additions and 3 deletions

View File

@ -149,9 +149,8 @@ private:
else if (t.type2.symbol !is null) else if (t.type2.symbol !is null)
{ {
// TODO: global scoped symbol handling // TODO: global scoped symbol handling
string[] symbolParts = cast(string[]) Mallocator.it.allocate( size_t l = t.type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances.length;
t.type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances.length string[] symbolParts = (cast(string*) Mallocator.it.allocate(l * string.sizeof))[0 .. l];
* string.sizeof);
scope(exit) Mallocator.it.deallocate(symbolParts); scope(exit) Mallocator.it.deallocate(symbolParts);
expandSymbol(symbolParts, t.type2.symbol.identifierOrTemplateChain); expandSymbol(symbolParts, t.type2.symbol.identifierOrTemplateChain);
auto symbols = moduleScope.getSymbolsByNameAndCursor( auto symbols = moduleScope.getSymbolsByNameAndCursor(
@ -179,7 +178,10 @@ private:
{ {
auto identOrTemplate = chain.identifiersOrTemplateInstances[i]; auto identOrTemplate = chain.identifiersOrTemplateInstances[i];
if (identOrTemplate is null) if (identOrTemplate is null)
{
strings[i] = null;
continue; continue;
}
strings[i] = internString(identOrTemplate.templateInstance is null ? strings[i] = internString(identOrTemplate.templateInstance is null ?
identOrTemplate.identifier.text identOrTemplate.identifier.text
: identOrTemplate.templateInstance.identifier.text); : identOrTemplate.templateInstance.identifier.text);