summaryrefslogtreecommitdiff
path: root/src/ir/module-utils.h
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/ir/module-utils.h
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/ir/module-utils.h')
-rw-r--r--src/ir/module-utils.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index c03015f41..b488db765 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -105,7 +105,7 @@ inline void copyModule(Module& in, Module& out) {
// we use names throughout, not raw points, so simple copying is fine
// for everything *but* expressions
for (auto& curr : in.functionTypes) {
- out.addFunctionType(new FunctionType(*curr));
+ out.addFunctionType(make_unique<FunctionType>(*curr));
}
for (auto& curr : in.exports) {
out.addExport(new Export(*curr));