add exception handling code for null return 11/160011/1 accepted/tizen/4.0/unified/20171115.173814 submit/tizen_4.0/20171114.071830
authorCho Woong Suk <ws77.cho@samsung.com>
Tue, 14 Nov 2017 06:32:31 +0000 (15:32 +0900)
committerCho Woong Suk <ws77.cho@samsung.com>
Tue, 14 Nov 2017 06:32:31 +0000 (15:32 +0900)
Change-Id: I41834f55e6d8d9e33a8d76bead8b281aec2c1a65

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

index aaeefd6..58beb13 100644 (file)
@@ -177,7 +177,10 @@ void 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 a3ad62b..260344d 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");
+                       }
                };
                Launchpad.loaderMain(argc, argv);
        }