From 3e3d508f3fa04835c34edc480f1cb9be4d3f8867 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 14 Nov 2017 15:32:31 +0900 Subject: [PATCH] add exception handling code for null return Change-Id: I41834f55e6d8d9e33a8d76bead8b281aec2c1a65 --- NativeLauncher/launcher/launcher.cc | 5 ++++- NativeLauncher/launcher/main.cc | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index 91c24a1..e0b5ed0 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -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; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 6fcfb9b..6c1ac12 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -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) { -- 2.7.4