diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-27 16:48:34 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-27 17:00:37 -0700 |
commit | 5512058de8984a0a782e9af055b9a7e6b3d0fa40 (patch) | |
tree | d2e6ec5b7dfa2aafd90cda29a8d8aae738ac35e7 /src | |
parent | 09d356d7438ea9a9497820fc2fbf9c018ea0d139 (diff) | |
download | binaryen-5512058de8984a0a782e9af055b9a7e6b3d0fa40.tar.gz binaryen-5512058de8984a0a782e9af055b9a7e6b3d0fa40.tar.bz2 binaryen-5512058de8984a0a782e9af055b9a7e6b3d0fa40.zip |
avoid leaks when s-parsing hits an error
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-s-parser.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 02d202718..a2a0e0027 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -1112,14 +1112,14 @@ private: wasm.memory.exportName = s[1]->str(); return; } - auto ex = new Export; + std::unique_ptr<Export> ex = make_unique<Export>(); ex->name = s[1]->str(); ex->value = s[2]->str(); - wasm.addExport(ex); + wasm.addExport(ex.release()); } void parseImport(Element& s) { - auto im = new Import; + std::unique_ptr<Import> im = make_unique<Import>(); size_t i = 1; if (s.size() > 3 && s[3]->isStr()) { im->name = s[i++]->str(); @@ -1154,7 +1154,7 @@ private: } } im->type = ensureFunctionType(getSig(type.get()), &wasm); - wasm.addImport(im); + wasm.addImport(im.release()); } void parseTable(Element& s) { @@ -1164,7 +1164,7 @@ private: } void parseType(Element& s) { - auto type = new FunctionType; + std::unique_ptr<FunctionType> type = make_unique<FunctionType>(); size_t i = 1; if (s[i]->isStr()) { type->name = s[i]->str(); @@ -1182,7 +1182,7 @@ private: type->result = stringToWasmType(curr[1]->str()); } } - wasm.addFunctionType(type); + wasm.addFunctionType(type.release()); } }; |