bug-fix: to pass argument, change exectuable name to appid 22/147522/1 accepted/tizen/unified/20170905.184439 submit/tizen/20170905.001811
authorCho Woong Suk <ws77.cho@samsung.com>
Mon, 4 Sep 2017 23:58:51 +0000 (08:58 +0900)
committerCho Woong Suk <ws77.cho@samsung.com>
Mon, 4 Sep 2017 23:58:51 +0000 (08:58 +0900)
Change-Id: I1873bec7879c97c449060b98c895d8437a3a45f4

NativeLauncher/launcher/main.cc

index b532832..a3ad62b 100644 (file)
@@ -37,6 +37,8 @@
 #define LAUNCHER_VERSION_STR __STR(VERSION)
 #endif
 
+#define CMD_LINE_SIZE  24      // sizeof("/usr/bin/dotnet-launcher")
+
 static std::string VersionOption("--version");
 static std::string StandaloneOption("--standalone");
 
@@ -45,7 +47,6 @@ int main(int argc, char *argv[])
        int i;
        bool standalone = false;
        char* standalonePath = nullptr;
-       int cmdlineSize = 0;
 
        std::vector<char*> vargs;
 
@@ -62,11 +63,10 @@ int main(int argc, char *argv[])
                                return 1;
                        }
                        i++;
-                       standalonePath = strdup(argv[i]);
+                       standalonePath = argv[i];
                } else {
                        vargs.push_back(argv[i]);
                }
-               cmdlineSize += (strlen(argv[i]) +1);
        }
 
        using tizen::runtime::LauncherInterface;
@@ -100,8 +100,8 @@ int main(int argc, char *argv[])
                }
 
                // change cmdline from dotnet-launcher to executable path
-               memset(argv[0], '\0', cmdlineSize);
-               snprintf(argv[0], cmdlineSize, "%s", standalonePath);
+               memset(argv[0], '\0', CMD_LINE_SIZE);
+               snprintf(argv[0], CMD_LINE_SIZE - 1, "%s", appId);
 
                int argsLen = vargs.size();
                char** args = &vargs[0];
@@ -132,10 +132,6 @@ int main(int argc, char *argv[])
                Launchpad.loaderMain(argc, argv);
        }
 
-       if (standalonePath != nullptr) {
-               free(standalonePath);
-       }
-
        runtime->dispose();
        return 0;
 }