From 51a481f6ed9e39b284421778b63b265eca6c1b58 Mon Sep 17 00:00:00 2001 From: Paweł Bylica Date: Thu, 10 Jan 2019 17:23:08 +0100 Subject: 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. --- src/ir/module-utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ir/module-utils.h') 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(*curr)); } for (auto& curr : in.exports) { out.addExport(new Export(*curr)); -- cgit v1.2.3