Fix memory leak when error happened 76/279176/5 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/20221110.061339 accepted/tizen/7.0/unified/hotfix/20221116.104720 accepted/tizen/unified/20220805.131846 submit/tizen/20220804.015955 tizen_7.0_m2_release
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:36 +0000 (16:43 +0900)
[Version] 0.1.40
[Issue Type] Fix memory leak

Change-Id: I4eccf66004398a307369d6c61e552b788f05892f

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

index dab625cbf98cd263fce81d6261573386f1d2adcc..5b60c045a40b3b2029a87531ac861297c2bb423f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-mediademuxer
 Summary:    A Media Demuxer library in Tizen Native API
-Version:    0.1.39
+Version:    0.1.40
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d3132d4951f73ac26d4bf68f99c3612fe9417f21..3305cd9dd71babf73ba6eecca6f8ca00b1428dc9 100644 (file)
@@ -973,7 +973,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) {
@@ -982,18 +982,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;
 }