diff options
author | Chengwei Yang <chengwei.yang@intel.com> | 2013-01-15 16:11:07 +0800 |
---|---|---|
committer | Gerrit Code Review <gerrit2@kim11> | 2013-01-25 16:06:37 +0900 |
commit | c8c915634c86e641f418875d58b9167a06b5d63a (patch) | |
tree | c63050565ab7d74cfe22588cc79f48cca8a3b402 | |
parent | 568b6c8e9e9642da911a1078af872ef330bdaeb5 (diff) | |
download | aul-1-c8c915634c86e641f418875d58b9167a06b5d63a.tar.gz aul-1-c8c915634c86e641f418875d58b9167a06b5d63a.tar.bz2 aul-1-c8c915634c86e641f418875d58b9167a06b5d63a.zip |
Check pointer before unreference to avoid crash
Change-Id: If8a28f1e89aef4f33b25aea2337fbd18cc1f7399
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
-rwxr-xr-x | include/menu_db_util.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/include/menu_db_util.h b/include/menu_db_util.h index f05b9dab..bbd569be 100755 --- a/include/menu_db_util.h +++ b/include/menu_db_util.h @@ -52,9 +52,7 @@ typedef struct { static inline char *_get_pkgname(app_info_from_db *menu_info) { - if (menu_info->pkg_name == NULL) - return NULL; - return menu_info->pkg_name; + return menu_info ? menu_info->pkg_name : NULL; } static inline char *_get_app_path(app_info_from_db *menu_info) @@ -62,7 +60,7 @@ static inline char *_get_app_path(app_info_from_db *menu_info) int i = 0; int path_len = -1; - if (menu_info->app_path == NULL) + if (!menu_info || menu_info->app_path == NULL) return NULL; while (menu_info->app_path[i] != 0) { @@ -91,9 +89,7 @@ static inline char *_get_app_path(app_info_from_db *menu_info) static inline char *_get_original_app_path(app_info_from_db *menu_info) { - if (menu_info->original_app_path == NULL) - return NULL; - return menu_info->original_app_path; + return menu_info ? menu_info->original_app_path : NULL; } static inline void _free_app_info_from_db(app_info_from_db *menu_info) @@ -168,12 +164,18 @@ static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *use { app_info_from_db *menu_info = (app_info_from_db *)user_data; char *package; + ail_cb_ret_e ret = AIL_CB_RET_CONTINUE; + + if (!menu_info) + return ret; ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package); + if (package) { + menu_info->pkg_name = strdup(package); + ret = AIL_CB_RET_CANCEL; + } - menu_info->pkg_name = strdup(package); - - return AIL_CB_RET_CANCEL; /*return AIL_CB_RET_CONTINUE;*/ + return ret; } static inline app_info_from_db *_get_app_info_from_db_by_apppath( |