From 7ed6d94a585cb9ed9fea537924a858bd6c03a267 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Tue, 27 May 2014 11:09:18 -0700 Subject: [PATCH] Fix memory corruption issue --- conversion/third.d | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/conversion/third.d b/conversion/third.d index 59bee29..9d34561 100644 --- a/conversion/third.d +++ b/conversion/third.d @@ -149,9 +149,8 @@ private: else if (t.type2.symbol !is null) { // TODO: global scoped symbol handling - string[] symbolParts = cast(string[]) Mallocator.it.allocate( - t.type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances.length - * string.sizeof); + size_t l = t.type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances.length; + string[] symbolParts = (cast(string*) Mallocator.it.allocate(l * string.sizeof))[0 .. l]; scope(exit) Mallocator.it.deallocate(symbolParts); expandSymbol(symbolParts, t.type2.symbol.identifierOrTemplateChain); auto symbols = moduleScope.getSymbolsByNameAndCursor( @@ -179,7 +178,10 @@ private: { auto identOrTemplate = chain.identifiersOrTemplateInstances[i]; if (identOrTemplate is null) + { + strings[i] = null; continue; + } strings[i] = internString(identOrTemplate.templateInstance is null ? identOrTemplate.identifier.text : identOrTemplate.templateInstance.identifier.text);