summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-27 16:33:30 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-27 17:00:37 -0700
commit09d356d7438ea9a9497820fc2fbf9c018ea0d139 (patch)
treed40675439a4cca61a8400ef9fd5bbe9ae5c7cb7a
parent36b8c029b90c9f0dd3ba564cf040dadbbe96d970 (diff)
downloadbinaryen-09d356d7438ea9a9497820fc2fbf9c018ea0d139.tar.gz
binaryen-09d356d7438ea9a9497820fc2fbf9c018ea0d139.tar.bz2
binaryen-09d356d7438ea9a9497820fc2fbf9c018ea0d139.zip
don't leak currFunction in s-parser
-rw-r--r--src/wasm-s-parser.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 9c2feb5e6..02d202718 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -316,7 +316,7 @@ private:
}
// function parsing state
- Function *currFunction = nullptr;
+ std::unique_ptr<Function> currFunction;
std::map<Name, WasmType> currLocalTypes;
size_t localIndex; // params and vars
size_t otherIndex;
@@ -362,12 +362,12 @@ private:
Name type;
Block* autoBlock = nullptr; // we may need to add a block for the very top level
auto makeFunction = [&]() {
- currFunction = Builder(wasm).makeFunction(
+ currFunction = std::unique_ptr<Function>(Builder(wasm).makeFunction(
name,
std::move(params),
result,
std::move(vars)
- );
+ ));
};
for (;i < s.size(); i++) {
Element& curr = *s[i];
@@ -438,10 +438,9 @@ private:
assert(currFunction->result == result);
currFunction->body = body;
currFunction->type = type;
- wasm.addFunction(currFunction);
+ wasm.addFunction(currFunction.release());
currLocalTypes.clear();
labelStack.clear();
- currFunction = nullptr;
}
WasmType stringToWasmType(IString str, bool allowError=false, bool prefix=false) {