Fix wrong implementation of launchpad library 29/293729/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 2 Jun 2023 06:50:27 +0000 (06:50 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 2 Jun 2023 07:10:26 +0000 (07:10 +0000)
The context pointer must not be the unique_ptr. If it's the unique_ptr,
the unique_ptr tries to release the pointer.

Change-Id: I3e961ebdae813e685095a4b9c74b1221c8799860
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launchpad/launchpad_loader.cc

index b9092afb310d9330086a9585d916883036df2631..6ee82f17a6ebcd853635c7f6711cad1d474ba56d 100644 (file)
@@ -45,12 +45,17 @@ const uint32_t kMaxRetryingCount = 600;
 constexpr const char kLaunchpadLoaderSocketName[] = ".launchpad-type";
 
 tizen_base::Bundle loader_bundle;
-std::unique_ptr<LaunchpadLoader> context;
+LaunchpadLoader* context = nullptr;
 
 }  // namespace
 
 LaunchpadLoader::LaunchpadLoader(int argc, char** argv)
     : argc_(argc), argv_(argv) {
+  if (context != nullptr) {
+    _E("Already exists");
+    THROW(-EALREADY);
+  }
+
   if (argc_ < 4) {
     _E("Too few argument");
     THROW(-EINVAL);
@@ -70,7 +75,7 @@ LaunchpadLoader::LaunchpadLoader(int argc, char** argv)
 
   loader_id_ = atoi(argv_[LOADER_ARG_ID]);
   _W("loader type: %d, loader id: %d", loader_type_, loader_id_);
-  context.reset(this);
+  context = this;
 }
 
 LaunchpadLoader::~LaunchpadLoader() {
@@ -80,6 +85,8 @@ LaunchpadLoader::~LaunchpadLoader() {
 
     free(app_argv_);
   }
+
+  context = nullptr;
 }
 
 void LaunchpadLoader::Run(loader_lifecycle_callback_s* callback,