diff options
author | Alon Zakai <azakai@google.com> | 2019-06-30 08:41:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-30 08:41:36 -0700 |
commit | ebbcde7585ccfa0217bcf7557dc7f66553f36fcf (patch) | |
tree | ae4315ba8d857c9d7a50fef971ce36ee977de738 /src/passes/Bysyncify.cpp | |
parent | 78287cefb34e8bbbcd5b1c8bfedbf33162ecaaa5 (diff) | |
download | binaryen-ebbcde7585ccfa0217bcf7557dc7f66553f36fcf.tar.gz binaryen-ebbcde7585ccfa0217bcf7557dc7f66553f36fcf.tar.bz2 binaryen-ebbcde7585ccfa0217bcf7557dc7f66553f36fcf.zip |
Bysyncify: ensure memory exists (#2188)
We need memory in order to read and write rewinding info, so add it if the module didn't have any memory at all.
Found by the fuzzer.
Diffstat (limited to 'src/passes/Bysyncify.cpp')
-rw-r--r-- | src/passes/Bysyncify.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/passes/Bysyncify.cpp b/src/passes/Bysyncify.cpp index e798be562..f1e6c9f7d 100644 --- a/src/passes/Bysyncify.cpp +++ b/src/passes/Bysyncify.cpp @@ -202,6 +202,7 @@ #include "ir/effects.h" #include "ir/literal-utils.h" +#include "ir/memory-utils.h" #include "ir/module-utils.h" #include "ir/utils.h" #include "pass.h" @@ -948,6 +949,10 @@ private: struct Bysyncify : public Pass { void run(PassRunner* runner, Module* module) override { bool optimize = runner->options.optimizeLevel > 0; + + // Ensure there is a memory, as we need it. + MemoryUtils::ensureExists(module->memory); + // Find which things can change the state. auto stateChangingImports = runner->options.getArgumentOrDefault("bysyncify-imports", ""); |