Fix coverity issue - Read from pointer after free 59/223259/1 accepted/tizen/unified/20200205.125313 submit/tizen/20200204.080130 submit/tizen/20200204.110420
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 28 Jan 2020 05:29:19 +0000 (14:29 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 28 Jan 2020 05:29:19 +0000 (14:29 +0900)
[Version] 0.3.17
[Profile] Common
[Issue Type] Coverity

Change-Id: Ic2ca9ea401815e3b6fcdf633619cd5df2075a770
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
muse/src/muse_recorder_dispatcher.c
packaging/mmsvc-recorder.spec

index 8392b0b..9e85ef2 100644 (file)
@@ -527,39 +527,42 @@ static int _recorder_remove_export_data(muse_module_h module, tbm_fd fd, int rem
 
        while (tmp_list) {
                export_data = (muse_recorder_export_data *)tmp_list->data;
-               if (export_data) {
-                       if (export_data->fd == fd || remove_all) {
-                               /*LOGD("fd %d matched, remove it (remove_all %d)", fd, remove_all);*/
-
-                               if (export_data->bo) {
-                                       tbm_bo_unref(export_data->bo);
-                                       export_data->bo = NULL;
-                               } else {
-                                       LOGW("bo for fd %d is NULL", fd);
-                               }
-
-                               /* close exported fd */
-                               close(export_data->fd);
-                               export_data->fd = -1;
-
-                               muse_recorder->data_list = g_list_remove(muse_recorder->data_list, export_data);
-
-                               g_free(export_data);
-                               export_data = NULL;
-
-                               if (remove_all == FALSE) {
-                                       /*LOGD("fd %d, remove done", fd);*/
-                                       g_mutex_unlock(&muse_recorder->list_lock);
-                                       return TRUE;
-                               } else {
-                                       LOGD("check next data");
-                               }
-                       }
-               } else {
+
+               tmp_list = tmp_list->next;
+
+               if (export_data == NULL) {
                        LOGW("NULL data");
+                       continue;
                }
 
-               tmp_list = tmp_list->next;
+               if (export_data->fd != fd && remove_all == FALSE)
+                       continue;
+
+               /*LOGD("fd %d matched, remove it (remove_all %d)", fd, remove_all);*/
+
+               if (export_data->bo) {
+                       tbm_bo_unref(export_data->bo);
+                       export_data->bo = NULL;
+               } else {
+                       LOGW("bo for fd %d is NULL", fd);
+               }
+
+               /* close exported fd */
+               close(export_data->fd);
+               export_data->fd = -1;
+
+               muse_recorder->data_list = g_list_remove(muse_recorder->data_list, export_data);
+
+               g_free(export_data);
+               export_data = NULL;
+
+               if (remove_all == FALSE) {
+                       /*LOGD("fd %d, remove done", fd);*/
+                       g_mutex_unlock(&muse_recorder->list_lock);
+                       return TRUE;
+               } else {
+                       LOGD("check next data");
+               }
        }
 
        g_mutex_unlock(&muse_recorder->list_lock);
index ed3744c..222f02a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-recorder
 Summary:    A Recorder module for muse server
-Version:    0.3.16
+Version:    0.3.17
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0