From b2d313a2ffe34ae506210db1d4240da77d7f67a6 Mon Sep 17 00:00:00 2001 From: Tae-Jeong Lee Date: Tue, 8 Oct 2013 18:17:05 +0900 Subject: [PATCH] Fix Prevent issue [Issue#] CID: 17523 [Problem] Resource leak. [Cause] There was allocated memory resources that we intentionally keep it not to be released until its process terminates. [Solution] Use atexit() to release resources properly. Change-Id: I05658e633d9c7537731368a5e0ec27a76355bebe --- .../include/process_pool_launchpad_util.h | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h b/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h index 0026e2b..ce4cd97 100644 --- a/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h +++ b/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h @@ -23,6 +23,7 @@ #ifndef __PROCESS_POOL_LAUNCHPAD_UTIL_H_ #define __PROCESS_POOL_LAUNCHPAD_UTIL_H_ +#include #include #include @@ -73,6 +74,16 @@ _static_ int __process_pool_prepare_exec(const char *pkg_name, return 0; } + +static bundle *_s_bundle = NULL; +static void __at_exit_to_release_bundle() +{ + if (_s_bundle) { + bundle_free(_s_bundle); + _s_bundle = NULL; + } +} + _static_ void process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv) { @@ -88,6 +99,12 @@ _static_ void process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_pat exit(-1); } + if (_s_bundle != NULL) { + bundle_free(_s_bundle); + } + _s_bundle = kb; + atexit(__at_exit_to_release_bundle); + pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME); SECURE_LOGD("pkg name : %s", pkg_name); @@ -134,16 +151,9 @@ _static_ void process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_pat exit(-1); } - -#if 0 // intentional if (menu_info != NULL) { _free_app_info_from_db(menu_info); } - - if (kb != NULL) { - bundle_free(kb); - } -#endif } -#endif // __PROCESS_POOL_LAUNCHPAD_UTIL_H_ \ No newline at end of file +#endif // __PROCESS_POOL_LAUNCHPAD_UTIL_H_ -- 2.7.4