From: Junghyun Yeon Date: Tue, 12 Jan 2021 04:57:19 +0000 (+0900) Subject: Fix memory leak X-Git-Tag: accepted/tizen/6.0/unified/20210120.085708~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9042be6419320211c4c4d73067ed0db8a84083a0;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git Fix memory leak Related changes: [app-installers] : https://review.tizen.org/gerrit/251120 Change-Id: I965336477aeec7dd2dae2dd274514c1fbc9c5199 Signed-off-by: Junghyun Yeon --- diff --git a/src/hybrid/hybrid_installer_factory.cc b/src/hybrid/hybrid_installer_factory.cc index ed9cf2a..1716765 100644 --- a/src/hybrid/hybrid_installer_factory.cc +++ b/src/hybrid/hybrid_installer_factory.cc @@ -25,7 +25,8 @@ namespace hybrid { std::unique_ptr HybridInstallerFactory::CreateInstaller( ci::PkgMgrPtr pkgmgr, int idx) { std::unique_ptr installer; - wgt::WgtAppQueryInterface* wgt_aqi = new wgt::WgtAppQueryInterface(); + std::shared_ptr wgt_aqi( + new wgt::WgtAppQueryInterface()); pkgmgr->AddAppQueryInterface(idx, wgt_aqi); installer.reset(new hybrid::HybridInstaller(pkgmgr)); diff --git a/src/wgt/wgt_installer_factory.cc b/src/wgt/wgt_installer_factory.cc index 54d191e..f260647 100644 --- a/src/wgt/wgt_installer_factory.cc +++ b/src/wgt/wgt_installer_factory.cc @@ -25,7 +25,7 @@ namespace wgt { std::unique_ptr WgtInstallerFactory::CreateInstaller( ci::PkgMgrPtr pkgmgr, int idx) { std::unique_ptr installer; - WgtAppQueryInterface* wgt_aqi = new WgtAppQueryInterface(); + std::shared_ptr wgt_aqi(new WgtAppQueryInterface()); pkgmgr->AddAppQueryInterface(idx, wgt_aqi); installer.reset(new wgt::WgtInstaller(pkgmgr)); diff --git a/src/wgt_backend/wgt_backend.cc b/src/wgt_backend/wgt_backend.cc index 3286b08..54c070f 100644 --- a/src/wgt_backend/wgt_backend.cc +++ b/src/wgt_backend/wgt_backend.cc @@ -28,10 +28,11 @@ std::unique_ptr make_unique(Args&&... args) { int main(int argc, char** argv) { ci::PkgmgrInstaller pkgmgr_installer; - wgt::WgtAppQueryInterface query_interface; + std::shared_ptr query_interface( + new wgt::WgtAppQueryInterface()); try { auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer, - &query_interface); + query_interface); std::unique_ptr installer_factory; if (!pkgmgr) { LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; @@ -43,7 +44,7 @@ int main(int argc, char** argv) { #endif // This is workaround for hybrid apps as they requires much different flow // but installer does not branch at all in current design - if (query_interface.IsHybridApplication( + if (query_interface->IsHybridApplication( pkgmgr->GetRequestInfo(), pkgmgr->GetUid())) { LOG(INFO) << "Hybrid package detected"; ci::InstallerRunner runner( diff --git a/test/smoke_tests/smoke_test_helper.cc b/test/smoke_tests/smoke_test_helper.cc index a52afa2..45dbacc 100644 --- a/test/smoke_tests/smoke_test_helper.cc +++ b/test/smoke_tests/smoke_test_helper.cc @@ -38,9 +38,10 @@ int main(int argc, char** argv) { } ci::PkgmgrInstaller pkgmgr_installer; - wgt::WgtAppQueryInterface query_interface; + std::shared_ptr query_interface( + new wgt::WgtAppQueryInterface()); auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, - &pkgmgr_installer, &query_interface); + &pkgmgr_installer, query_interface); if (!pkgmgr) { LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; return EINVAL;