From ae235498caab878420dff6ee21ecb40d4ccedeef Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Wed, 19 Jul 2017 10:00:55 +0900 Subject: [PATCH] [SATIZENVUL-953] Add check for memory allocation And bug fix (svace issue) Change-Id: Ifccef06a0ea8a48c8528a3a9bb3bd3759cf71c98 Signed-off-by: Minje Ahn --- lib/media-util-register.c | 6 +++--- src/common/media-common-db-svc.c | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/media-util-register.c b/lib/media-util-register.c index 50f4974..2806ad5 100755 --- a/lib/media-util-register.c +++ b/lib/media-util-register.c @@ -186,11 +186,11 @@ gboolean _read_socket(GIOChannel *src, GIOCondition condition, gpointer data) unlink(sock_path); MS_SAFE_FREE(sock_path); } - } - MSAPI_DBG("REMOVE OK"); + MSAPI_DBG("REMOVE OK"); - break; + break; + } } } g_mutex_unlock(&scan_req_mutex); diff --git a/src/common/media-common-db-svc.c b/src/common/media-common-db-svc.c index 374aff1..60f83e7 100755 --- a/src/common/media-common-db-svc.c +++ b/src/common/media-common-db-svc.c @@ -934,8 +934,13 @@ int ms_get_storage_list(void **handle, GArray **storage_array) if (count != 0) { for (i = 0; i < count; i++) { stg_info = malloc(sizeof(ms_stg_info_s)); - stg_info->stg_path = strdup(storage_list[i]); - stg_info->storage_id = strdup(storage_id_list[i]); + if (stg_info == NULL) { + MS_DBG_ERR("Allcation failed"); + continue; + } + + stg_info->stg_path = g_strdup(storage_list[i]); + stg_info->storage_id = g_strdup(storage_id_list[i]); stg_info->scan_status = scan_status[i]; g_array_append_val(*storage_array, stg_info); MS_SAFE_FREE(storage_list[i]); -- 2.7.4