Fix memory leak when error happened 75/279175/5 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20220805.131714 submit/tizen_6.5/20220804.015945
authorGilbok Lee <gilbok.lee@samsung.com>
Wed, 3 Aug 2022 06:23:44 +0000 (15:23 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 3 Aug 2022 07:43:47 +0000 (16:43 +0900)
[Version] 0.1.38
[Issue Type] Fix memory leak

Change-Id: I4eccf66004398a307369d6c61e552b788f05892f

packaging/capi-mediademuxer.spec
src/port_gst/mediademuxer_port_gst.c

index c5b4be739c98423f0d6e312984044b053be6dd61..f4351186f5a6b0c1e8e10d121db15b38fcb62b34 100644 (file)
@@ -1,7 +1,7 @@
 Name:       capi-mediademuxer
 Summary:    A Media Demuxer library in Tizen Native API
-Version:    0.1.37
-Release:    1
+Version:    0.1.38
+Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index d53637f02325ce1e69b7316d8389008cb32b4a8b..e75ad5fff174e76413bb03e4ffcc516edeb9b26c 100644 (file)
@@ -967,7 +967,7 @@ static int __gst_create_pipeline(mdgst_handle_t *gst_handle, char *uri)
        gst_object_unref(GST_OBJECT(bus));
 
        /* set pipeline state to PAUSED */
-       MEDIADEMUXER_SET_STATE(gst_handle->pipeline, GST_STATE_PAUSED, ERROR);
+       MEDIADEMUXER_SET_STATE(gst_handle->pipeline, GST_STATE_PAUSED, ERROR_STATE_CHANGE);
 
        if (gst_element_get_state(gst_handle->pipeline, &element_state, &element_pending_state, 1 * GST_SECOND)
                == GST_STATE_CHANGE_FAILURE) {
@@ -976,18 +976,38 @@ static int __gst_create_pipeline(mdgst_handle_t *gst_handle, char *uri)
                        gst_element_state_get_name(element_state),
                        gst_element_state_get_name(element_pending_state));
                ret = MD_ERROR;
-               goto ERROR;
+               goto ERROR_STATE_CHANGE;
        }
 
-       if (gst_handle->is_prepared != true) {
+       if (!gst_handle->is_prepared) {
                MD_E("Error occur");
                ret = MD_ERROR;
-               goto ERROR;
+               goto ERROR_STATE_CHANGE;
        }
 
        MEDIADEMUXER_FLEAVE();
        return ret;
+
 ERROR:
+       if (gst_handle->filesrc)
+               gst_object_unref(gst_handle->filesrc);
+
+       if (gst_handle->typefind)
+               gst_object_unref(gst_handle->typefind);
+
+       if (gst_handle->fakesink)
+               gst_object_unref(gst_handle->fakesink);
+
+ERROR_STATE_CHANGE:
+       if (gst_handle->pipeline) {
+               gst_object_unref(gst_handle->pipeline);
+               gst_handle->pipeline = NULL;
+       }
+
+       gst_handle->filesrc = NULL;
+       gst_handle->typefind = NULL;
+       gst_handle->fakesink = NULL;
+
        MEDIADEMUXER_FLEAVE();
        return ret;
 }