summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorPaweł Bylica <chfast@gmail.com>2019-01-10 17:23:08 +0100
committerAlon Zakai <alonzakai@gmail.com>2019-01-10 08:23:08 -0800
commit51a481f6ed9e39b284421778b63b265eca6c1b58 (patch)
treecf55edd7cc08dddc18900fe4f8badb4b39dbf837 /src/wasm/wasm-s-parser.cpp
parente71506165996f7a12cd54361761bc88c7f883cd2 (diff)
downloadbinaryen-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/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 0dfea962b..f5280bc33 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -421,7 +421,7 @@ void SExpressionWasmBuilder::preParseFunctionType(Element& s) {
functionType->name = Name::fromInt(wasm.functionTypes.size());
functionTypeNames.push_back(functionType->name);
if (wasm.getFunctionTypeOrNull(functionType->name)) throw ParseException("duplicate function type", s.line, s.col);
- wasm.addFunctionType(functionType.release());
+ wasm.addFunctionType(std::move(functionType));
}
}
}
@@ -1828,7 +1828,7 @@ void SExpressionWasmBuilder::parseType(Element& s) {
}
functionTypeNames.push_back(type->name);
if (wasm.getFunctionTypeOrNull(type->name)) throw ParseException("duplicate function type", s.line, s.col);
- wasm.addFunctionType(type.release());
+ wasm.addFunctionType(std::move(type));
}
} // namespace wasm