Fix dereference NULL 39/147939/1
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 6 Sep 2017 06:06:02 +0000 (15:06 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Wed, 6 Sep 2017 06:06:58 +0000 (15:06 +0900)
Change-Id: I29ee2cf5f1a6b0363ea75498a822a83674330c7b
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
screen_connector_watcher/src/screen_connector_watcher.c
screen_connector_watcher_evas/src/screen_connector_watcher_evas.c

index d4653a7..e9dd976 100644 (file)
@@ -155,8 +155,27 @@ static void __aul_screen_viewer_cb(const char *appid, const char *instance_id,
        screen_connector_info_h cur_info;
 
        LOGD("__aul_screen_viewer_cb pid: %d, surface_id: %d, appid: %s type %d", pid, surface_id, appid, event_type);
+
+       if (info == NULL) {
+               LOGE("Fail to alloc info");
+               return;
+       }
+
        info->appid = strdup(appid);
+       if (info->appid == NULL) {
+               LOGE("Fail to alloc appid");
+               free(info);
+               return;
+       }
+
        info->instance_id = strdup(instance_id);
+       if (info->instance_id == NULL) {
+               LOGE("Fail to alloc instance_id");
+               free(info->appid);
+               free(info);
+               return;
+       }
+
        info->pid = pid;
        info->surface_id = surface_id;
        info->ops = watcher_h->ops;
index b39b4cf..d5fa954 100644 (file)
@@ -76,9 +76,27 @@ static void __clear_img_file(img_info_h info)
 static img_info_h __create_img_info(const char *appid, const char *instance_id, int pid)
 {
        img_info_h info = (img_info_h)calloc(1, sizeof(struct _img_info_h));
+       if (info == NULL) {
+               LOGE("Fail to calloc img info");
+               return NULL;
+       }
+
        info->appid = strdup(appid);
+       if (info->appid == NULL) {
+               LOGE("Fail to strdup appid");
+               free(info);
+               return NULL;
+       }
+
        info->instance_id = strdup(instance_id);
+       if (info->instance_id == NULL) {
+               LOGE("Fail to strdup appid");
+               free(info->appid);
+               free(info);
+               return NULL;
+       }
        info->pid = pid;
+
        return info;
 }
 
@@ -160,6 +178,9 @@ static void __watcher_update_cb(struct tizen_remote_surface *trs, uint32_t type,
        info = g_hash_table_lookup(__img_info_table, instance_id);
        if (info == NULL) {
                info = __create_img_info(appid, instance_id, pid);
+               if (info == NULL)
+                       return;
+
                g_hash_table_insert(__img_info_table, strdup(instance_id), info);
        }