Modify argv creation of liblaunchpad library 63/299163/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2023 04:18:05 +0000 (13:18 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Sep 2023 04:22:40 +0000 (13:22 +0900)
The last element of the argv should be nullptr.
If the last element is not nullptr, the following error can be occurred:
"Failed to execute a file. path: <executable file path>, errno: 14(Bad address)"

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

index bfb301b..fdf50fd 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();
+  app_argc_ = exported_args.size() + 1;
   app_argv_ = static_cast<char**>(calloc(app_argc_, sizeof(char*)));
   if (app_argv_ == nullptr) {
     _E("calloc() is failed");
     exit(-ENOMEM);
   }
 
-  for (int i = 0; i < app_argc_; ++i) {
+  for (int i = 0; i < app_argc_ - 1; ++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());