Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix dereferencing null pointer when running wavm with WebAssembly mai…
…n function that takes command-line arguments but no Emscripten memory to write them to
  • Loading branch information
AndrewScheidecker committed Sep 16, 2018
1 parent bc7e031 commit 31d670b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Programs/wavm/wavm.cpp
Expand Up @@ -250,21 +250,23 @@ static int run(const CommandLineOptions& options)
{
if(functionType.params().size() == 2)
{
MemoryInstance* defaultMemory = Runtime::getDefaultMemory(moduleInstance);
if(!defaultMemory)
if(!emscriptenInstance)
{
Log::printf(
Log::error,
"Module does not declare a default memory object to put arguments in.\n");
return EXIT_FAILURE;
}
else
{
std::vector<const char*> argStrings;
argStrings.push_back(options.filename);
char** args = options.args;
while(*args) { argStrings.push_back(*args++); };

std::vector<const char*> argStrings;
argStrings.push_back(options.filename);
char** args = options.args;
while(*args) { argStrings.push_back(*args++); };

Emscripten::injectCommandArgs(emscriptenInstance, argStrings, invokeArgs);
wavmAssert(emscriptenInstance);
Emscripten::injectCommandArgs(emscriptenInstance, argStrings, invokeArgs);
}
}
else if(functionType.params().size() > 0)
{
Expand Down

0 comments on commit 31d670b

Please sign in to comment.