Fix memory leak 60/251260/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 12 Jan 2021 04:57:19 +0000 (13:57 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 12 Jan 2021 04:57:19 +0000 (13:57 +0900)
Related changes:
[app-installers] : https://review.tizen.org/gerrit/251120

Change-Id: I965336477aeec7dd2dae2dd274514c1fbc9c5199
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/hybrid/hybrid_installer_factory.cc
src/wgt/wgt_installer_factory.cc
src/wgt_backend/wgt_backend.cc
test/smoke_tests/smoke_test_helper.cc

index ed9cf2a73f1eb1b99f51113928ef7bf8b0690789..1716765c25040aebd144aec1704e6ccc4ed8af9b 100644 (file)
@@ -25,7 +25,8 @@ namespace hybrid {
 std::unique_ptr<ci::AppInstaller> HybridInstallerFactory::CreateInstaller(
     ci::PkgMgrPtr pkgmgr, int idx) {
   std::unique_ptr<ci::AppInstaller> installer;
-  wgt::WgtAppQueryInterface* wgt_aqi = new wgt::WgtAppQueryInterface();
+  std::shared_ptr<wgt::WgtAppQueryInterface> wgt_aqi(
+      new wgt::WgtAppQueryInterface());
 
   pkgmgr->AddAppQueryInterface(idx, wgt_aqi);
   installer.reset(new hybrid::HybridInstaller(pkgmgr));
index 54d191ec506993c00713b659000745911b1b74a3..f260647353061d6cebec74816c66a5bcdcd98cb0 100644 (file)
@@ -25,7 +25,7 @@ namespace wgt {
 std::unique_ptr<ci::AppInstaller> WgtInstallerFactory::CreateInstaller(
     ci::PkgMgrPtr pkgmgr, int idx) {
   std::unique_ptr<ci::AppInstaller> installer;
-  WgtAppQueryInterface* wgt_aqi = new WgtAppQueryInterface();
+  std::shared_ptr<WgtAppQueryInterface> wgt_aqi(new WgtAppQueryInterface());
 
   pkgmgr->AddAppQueryInterface(idx, wgt_aqi);
   installer.reset(new wgt::WgtInstaller(pkgmgr));
index 3286b0825bfa29b0d0f333eb2ba4eb519c6d0491..54c070f885dd00a2314e798b2fafcedb4ddd6df3 100644 (file)
@@ -28,10 +28,11 @@ std::unique_ptr<T> make_unique(Args&&... args) {
 
 int main(int argc, char** argv) {
   ci::PkgmgrInstaller pkgmgr_installer;
-  wgt::WgtAppQueryInterface query_interface;
+  std::shared_ptr<wgt::WgtAppQueryInterface> query_interface(
+      new wgt::WgtAppQueryInterface());
   try {
     auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer,
-                                              &query_interface);
+                                              query_interface);
     std::unique_ptr<ci::InstallerFactory> 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(
index a52afa2d097b5cf1936de67b23309011da25637a..45dbacc4230badb80ba7c5087990ffde139b6b35 100644 (file)
@@ -38,9 +38,10 @@ int main(int argc, char** argv) {
     }
 
     ci::PkgmgrInstaller pkgmgr_installer;
-    wgt::WgtAppQueryInterface query_interface;
+    std::shared_ptr<wgt::WgtAppQueryInterface> 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;