add exception handling code for null return 12/160012/1 accepted/tizen/unified/20171115.061209 submit/tizen/20171114.071938
authorCho Woong Suk <ws77.cho@samsung.com>
Tue, 14 Nov 2017 06:32:31 +0000 (15:32 +0900)
committerwoongsuk cho <ws77.cho@samsung.com>
Tue, 14 Nov 2017 06:33:34 +0000 (06:33 +0000)
Change-Id: I41834f55e6d8d9e33a8d76bead8b281aec2c1a65

NativeLauncher/launcher/launcher.cc
NativeLauncher/launcher/main.cc

index 91c24a1..e0b5ed0 100644 (file)
@@ -177,7 +177,10 @@ int LaunchpadAdapterImpl::loaderMain(int argc, char* argv[])
                                                const char* appId, const char* pkgId,
                                                const char* pkgType, void* userData) -> int {
                WITH_SELF(userData) {
-                       self->appInfo.root = std::string(aul_get_app_root_path());
+                       const char* appRootPath = aul_get_app_root_path();
+                       if (appRootPath != nullptr) {
+                               self->appInfo.root = std::string(appRootPath);
+                       }
                        self->appInfo.path = appPath;
                        self->appInfo.id = appId;
                        self->appInfo.pkg = pkgId;
index 6fcfb9b..6c1ac12 100644 (file)
@@ -123,11 +123,15 @@ int main(int argc, char *argv[])
                        _DBG("pkg : %s", appInfo.pkg.c_str());
                        _DBG("type : %s", appInfo.type.c_str());
 
-                       // The launchpad pass the name of exe file to the first argument.
-                       // For the C# spec, we have to skip this first argument.
-
-                       if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1))
-                               _ERR("Failed to launch");
+                       // aul_get_app_root_path() can return NULL for error case.
+                       if (appInfo.root.empty()) {
+                               _ERR("Failed to launch. root path is set to NULL");
+                       } else {
+                               // The launchpad pass the name of exe file to the first argument.
+                               // For the C# spec, we have to skip this first argument.
+                               if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1))
+                                       _ERR("Failed to launch");
+                       }
                };
                int ret = Launchpad.loaderMain(argc, argv);
                if (ret < 0) {