Fix wrong implmenetation of launchpad library 90/299190/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2023 08:31:39 +0000 (17:31 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2023 08:37:57 +0000 (17:37 +0900)
The argc should be the size of the result of Bundle::Export().

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

index fdf50fd..2f3faa1 100644 (file)
@@ -328,14 +328,14 @@ void LaunchpadLoader::ProcessLaunchRequest(tizen_base::Parcel* parcel) {
   Util::SetEnvironments(&app_info_);
   auto exported_args = app_info_.GetBundle().Export();
   exported_args[0] = app_info_.GetAppPath();
-  app_argc_ = exported_args.size() + 1;
-  app_argv_ = static_cast<char**>(calloc(app_argc_, sizeof(char*)));
+  app_argc_ = exported_args.size();
+  app_argv_ = static_cast<char**>(calloc(app_argc_ + 1, sizeof(char*)));
   if (app_argv_ == nullptr) {
     _E("calloc() is failed");
     exit(-ENOMEM);
   }
 
-  for (int i = 0; i < app_argc_ - 1; ++i) {
+  for (int i = 0; i < app_argc_; ++i) {
     app_argv_[i] = strdup(exported_args[i].c_str());
     if (app_argv_[i] == nullptr) {
       _E("strdup() is failed. [%d] %s", i, exported_args[i].c_str());