Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix out-of-bounds array access when passing a <4 byte input file to w…
…avm or wavm-compile
  • Loading branch information
AndrewScheidecker committed Sep 16, 2018
1 parent 234e8b9 commit 2de6cf7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Include/Inline/CLI.h
Expand Up @@ -144,7 +144,7 @@ inline bool loadModule(const char* filename, IR::Module& outModule)
if(!loadFile(filename, fileBytes)) { return false; }

// If the file starts with the WASM binary magic number, load it as a binary irModule.
if(*(U32*)fileBytes.data() == 0x6d736100)
if(fileBytes.size() >= 4 && *(U32*)fileBytes.data() == 0x6d736100)
{ return loadBinaryModule(fileBytes.data(), fileBytes.size(), outModule); }
else
{
Expand Down

0 comments on commit 2de6cf7

Please sign in to comment.