diff options
author | Paweł Bylica <chfast@gmail.com> | 2019-01-10 17:23:08 +0100 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2019-01-10 08:23:08 -0800 |
commit | 51a481f6ed9e39b284421778b63b265eca6c1b58 (patch) | |
tree | cf55edd7cc08dddc18900fe4f8badb4b39dbf837 /src/asmjs | |
parent | e71506165996f7a12cd54361761bc88c7f883cd2 (diff) | |
download | binaryen-51a481f6ed9e39b284421778b63b265eca6c1b58.tar.gz binaryen-51a481f6ed9e39b284421778b63b265eca6c1b58.tar.bz2 binaryen-51a481f6ed9e39b284421778b63b265eca6c1b58.zip |
Require unique_ptr to Module::addFunctionType() (#1672)
This fixes the memory leak in WasmBinaryBuilder::readSignatures() caused probably the exception thrown there before the FunctionType object is safe.
This also makes it clear that the Module becomes the owner of the FunctionType objects.
Diffstat (limited to 'src/asmjs')
-rw-r--r-- | src/asmjs/asm_v_wasm.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/asmjs/asm_v_wasm.cpp b/src/asmjs/asm_v_wasm.cpp index a937239f3..a0b3938fa 100644 --- a/src/asmjs/asm_v_wasm.cpp +++ b/src/asmjs/asm_v_wasm.cpp @@ -107,14 +107,13 @@ FunctionType* ensureFunctionType(std::string sig, Module* wasm) { return wasm->getFunctionType(name); } // add new type - auto type = new FunctionType; + auto type = make_unique<FunctionType>(); type->name = name; type->result = sigToType(sig[0]); for (size_t i = 1; i < sig.size(); i++) { type->params.push_back(sigToType(sig[i])); } - wasm->addFunctionType(type); - return type; + return wasm->addFunctionType(std::move(type)); } Expression* ensureDouble(Expression* expr, MixedArena& allocator) { |