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 ed9cf2a..1716765 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 54d191e..f260647 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 3286b08..54c070f 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 a52afa2..45dbacc 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;