diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-27 10:19:07 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-27 16:59:17 -0700 |
commit | 46f99e692014e714ffeed7f3db870ffd12bf077c (patch) | |
tree | 5f7182e5690fbe3212facd5769bd12ccb529f394 /src/binaryen-shell.cpp | |
parent | de7f3480d1ba898bc5ec270ef24b69f5408de633 (diff) | |
download | binaryen-46f99e692014e714ffeed7f3db870ffd12bf077c.tar.gz binaryen-46f99e692014e714ffeed7f3db870ffd12bf077c.tar.bz2 binaryen-46f99e692014e714ffeed7f3db870ffd12bf077c.zip |
don't leak when running tests in shell
Diffstat (limited to 'src/binaryen-shell.cpp')
-rw-r--r-- | src/binaryen-shell.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/binaryen-shell.cpp b/src/binaryen-shell.cpp index 4f2890969..509bd97dc 100644 --- a/src/binaryen-shell.cpp +++ b/src/binaryen-shell.cpp @@ -74,11 +74,11 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, Element* root, std::unique_ptr<SExpressionWasmBuilder>* builder, Name entry) { - ShellExternalInterface* interface = nullptr; - ModuleInstance* instance = nullptr; + std::unique_ptr<ShellExternalInterface> interface; + std::unique_ptr<ModuleInstance> instance; if (wasm) { - interface = new ShellExternalInterface(); - instance = new ModuleInstance(*wasm, interface); + interface = make_unique<ShellExternalInterface>(); + instance = make_unique<ModuleInstance>(*wasm, interface.get()); if (entry.is()) { Function* function = wasm->getFunction(entry); if (!function) { @@ -128,7 +128,7 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, assert(invalid); } else if (id == INVOKE) { assert(wasm); - Invocation invocation(curr, instance, *builder->get()); + Invocation invocation(curr, instance.get(), *builder->get()); invocation.invoke(); } else { // an invoke test @@ -136,7 +136,7 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, bool trapped = false; Literal result; try { - Invocation invocation(*curr[1], instance, *builder->get()); + Invocation invocation(*curr[1], instance.get(), *builder->get()); result = invocation.invoke(); } catch (const TrapException&) { trapped = true; |