[SATIZENVUL-953] Add check for memory allocation 05/139405/4
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 19 Jul 2017 01:00:55 +0000 (10:00 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 20 Jul 2017 07:18:18 +0000 (07:18 +0000)
And bug fix (svace issue)

Change-Id: Ifccef06a0ea8a48c8528a3a9bb3bd3759cf71c98
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
lib/media-util-register.c
src/common/media-common-db-svc.c

index 50f4974..2806ad5 100755 (executable)
@@ -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);
index 374aff1..60f83e7 100755 (executable)
@@ -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]);