From: Cho Woong Suk Date: Wed, 23 Aug 2017 06:24:40 +0000 (+0900) Subject: check return value of loaderMain to avoid crash X-Git-Tag: accepted/tizen/unified/20171106.073141~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F145618%2F4;p=platform%2Fcore%2Fdotnet%2Flauncher.git check return value of loaderMain to avoid crash Change-Id: Ib5a740a34c7f8b171fb890dc1f97c51e93ad647d --- diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index aaeefd6..91c24a1 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -53,7 +53,7 @@ class LaunchpadAdapterImpl : public LaunchpadAdapter launcher(nullptr), __isLaunched(false) { } - void loaderMain(int argc, char* argv[]) override; + int loaderMain(int argc, char* argv[]) override; std::map handlers; @@ -161,7 +161,7 @@ static void preloadLibsAndWindow(bundle *extra, int type, void *userData) elm_win_precreated_object_set(__win); } -void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) +int LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) { __argc = argc; __argv = argv; @@ -189,7 +189,6 @@ void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) return 0; }; callbacks.terminate = [](int argc, char **argv, void* userData) -> int { - _DBG("Terminate!!"); WITH_SELF(userData) { if (self->onTerminate != nullptr) self->onTerminate(self->appInfo, argc, argv); @@ -210,6 +209,8 @@ void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) _DBG("launchpad_loader_main is start"); int r = launchpad_loader_main(argc, argv, &(this->callbacks), &(this->adapter), this); _DBG("launchpad_loader_main is finished with [%d]", r); + + return r; } #undef WITH_SELF diff --git a/NativeLauncher/launcher/launcher.h b/NativeLauncher/launcher/launcher.h index 41ed2ac..ce91241 100644 --- a/NativeLauncher/launcher/launcher.h +++ b/NativeLauncher/launcher/launcher.h @@ -43,7 +43,7 @@ struct AppInfo { class LaunchpadAdapter { public: - virtual void loaderMain(int argc, char* argv[]) = 0; + virtual int loaderMain(int argc, char* argv[]) = 0; std::function onCreate = nullptr; std::function onLaunch = nullptr; std::function onTerminate = nullptr; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 0922908..6fcfb9b 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -129,7 +129,11 @@ int main(int argc, char *argv[]) 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); + int ret = Launchpad.loaderMain(argc, argv); + if (ret < 0) { + _DBG("fail to start loaderMain. candidate process is not created."); + return 1; + } } runtime->dispose();