Skip to content

Commit 46f99e6

Browse files
committed
don't leak when running tests in shell
1 parent de7f348 commit 46f99e6

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/binaryen-shell.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm,
7474
Element* root,
7575
std::unique_ptr<SExpressionWasmBuilder>* builder,
7676
Name entry) {
77-
ShellExternalInterface* interface = nullptr;
78-
ModuleInstance* instance = nullptr;
77+
std::unique_ptr<ShellExternalInterface> interface;
78+
std::unique_ptr<ModuleInstance> instance;
7979
if (wasm) {
80-
interface = new ShellExternalInterface();
81-
instance = new ModuleInstance(*wasm, interface);
80+
interface = make_unique<ShellExternalInterface>();
81+
instance = make_unique<ModuleInstance>(*wasm, interface.get());
8282
if (entry.is()) {
8383
Function* function = wasm->getFunction(entry);
8484
if (!function) {
@@ -128,15 +128,15 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm,
128128
assert(invalid);
129129
} else if (id == INVOKE) {
130130
assert(wasm);
131-
Invocation invocation(curr, instance, *builder->get());
131+
Invocation invocation(curr, instance.get(), *builder->get());
132132
invocation.invoke();
133133
} else {
134134
// an invoke test
135135
assert(wasm);
136136
bool trapped = false;
137137
Literal result;
138138
try {
139-
Invocation invocation(*curr[1], instance, *builder->get());
139+
Invocation invocation(*curr[1], instance.get(), *builder->get());
140140
result = invocation.invoke();
141141
} catch (const TrapException&) {
142142
trapped = true;

0 commit comments

Comments
 (0)