From: Kichan Kwon Date: Tue, 26 Sep 2017 06:39:23 +0000 (+0900) Subject: Fix memory issues X-Git-Tag: submit/tizen_4.0/20170926.084004^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a748363d141f648dbaba3d87c1fcfc0945a106aa;p=platform%2Fcore%2Fapi%2Fsystem-info.git Fix memory issues - Prevent accessing out of array - Free before exit Change-Id: Ifbe15353753438efb1b0f79951121d717cd57038 Signed-off-by: Kichan Kwon --- diff --git a/src/init_db/system_info_db_init.c b/src/init_db/system_info_db_init.c index 1647e34..06ae5f3 100644 --- a/src/init_db/system_info_db_init.c +++ b/src/init_db/system_info_db_init.c @@ -379,7 +379,7 @@ static int system_info_update_db(int argc, char *argv[]) break; } } - if (!runtime[rt].xml_prop) { + if (rt == LANG_MAX || !runtime[rt].xml_prop) { printf("Invalid language (%s)\n", optarg); return 0; } diff --git a/src/system_info.c b/src/system_info.c index a449063..acdb049 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -467,7 +467,7 @@ API int system_info_get_platform_type(const char *key, system_info_type_e *type) API int system_info_get_custom_type(const char *key, system_info_type_e *type) { int ret; - char *val; + char *val = NULL; size_t len; ret = system_info_get_type(TAG_TYPE_CUSTOM, key, type); @@ -492,9 +492,11 @@ API int system_info_get_custom_type(const char *key, system_info_type_e *type) *type = SYSTEM_INFO_STRING; else { _E("Invalid type (%s)", val); + free(val); return SYSTEM_INFO_ERROR_INVALID_PARAMETER; } + free(val); return SYSTEM_INFO_ERROR_NONE; //LCOV_EXCL_STOP }