diff --git a/compiler/codegen/ELFGenerator.cpp b/compiler/codegen/ELFGenerator.cpp index 5310d47e6b3..bc9ad3a7e33 100644 --- a/compiler/codegen/ELFGenerator.cpp +++ b/compiler/codegen/ELFGenerator.cpp @@ -339,9 +339,9 @@ void TR::ELFGenerator::writeELFSymbolsToFile(::FILE *fp) { - ELFSymbol * elfSym = static_cast(_rawAllocator.allocate(sizeof(ELFSymbol))); - char ELFSymbolNames[_totalELFSymbolNamesLength]; - + ELFSymbol *elfSym = static_cast(_rawAllocator.allocate(sizeof(ELFSymbol))); + char *ELFSymbolNames = static_cast(_rawAllocator.allocate(_totalELFSymbolNamesLength)); + /* Writing the UNDEF symbol*/ elfSym->st_name = 0; elfSym->st_info = 0; @@ -387,6 +387,7 @@ TR::ELFGenerator::writeELFSymbolsToFile(::FILE *fp) /* Finally, write the symbol names to file */ fwrite(ELFSymbolNames, sizeof(uint8_t), _totalELFSymbolNamesLength, fp); + _rawAllocator.deallocate(ELFSymbolNames); _rawAllocator.deallocate(elfSym); }