From 46f99e692014e714ffeed7f3db870ffd12bf077c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 27 Apr 2016 10:19:07 -0700 Subject: don't leak when running tests in shell --- src/binaryen-shell.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/binaryen-shell.cpp') 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* builder, Name entry) { - ShellExternalInterface* interface = nullptr; - ModuleInstance* instance = nullptr; + std::unique_ptr interface; + std::unique_ptr instance; if (wasm) { - interface = new ShellExternalInterface(); - instance = new ModuleInstance(*wasm, interface); + interface = make_unique(); + instance = make_unique(*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; -- cgit v1.2.3