Add missing g_array_unref() 55/245555/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 12 Oct 2020 08:48:45 +0000 (17:48 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 12 Oct 2020 08:49:31 +0000 (17:49 +0900)
It should be called after getting GArray pointer from
'get-transceivers' of webrtcbin.

[Version] 0.1.38
[Issue Type] Bug fix

Change-Id: I10564beba8579e59be95e475c9f38fd1baa733ab
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_private.c

index 739fc69a27d49cd888c510ae69f4c8b7184cd322..b2c2ef5e637135cdc41c9339bc949ce2d5afdf96 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.37
+Version:    0.1.38
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 9d60e579e2139fb6cfe78e1aa495e924ee050614..1583a7cf65f01aefc23a6502eda3b5a81dfcd1fb 100644 (file)
@@ -996,7 +996,7 @@ static int __convert_direction(GstWebRTCRTPTransceiverDirection gst_direction, w
 
 int _get_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e *direction)
 {
-       int ret = WEBRTC_ERROR_NONE;
+       int ret = WEBRTC_ERROR_INVALID_OPERATION;
        webrtc_gst_slot_s *source;
        GstWebRTCRTPTransceiver *trans;
        GArray *transceivers;
@@ -1025,21 +1025,24 @@ int _get_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_
                trans = g_array_index(transceivers, GstWebRTCRTPTransceiver *, i);
                if (trans->mline == mline) {
                        ret = __convert_direction(trans->direction, direction);
-                       if (ret != WEBRTC_ERROR_NONE)
-                               return ret;
-                       LOG_DEBUG("found transceiver[%p, index:%d, mline:%u, mid:%s, direction:%s]",
-                               trans, i, trans->mline, trans->mid, __direction_str[*direction]);
-                       return WEBRTC_ERROR_NONE;
+                       if (ret == WEBRTC_ERROR_NONE)
+                               LOG_DEBUG("found transceiver[%p, index:%d, mline:%u, mid:%s, direction:%s]",
+                                       trans, i, trans->mline, trans->mid, __direction_str[*direction]);
+                       goto end;
                }
        }
 
        LOG_ERROR("could not find a transceiver with mline[%d]", mline);
 
-       return WEBRTC_ERROR_INVALID_OPERATION;
+end:
+       g_array_unref(transceivers);
+
+       return ret;
 }
 
 int _set_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e direction)
 {
+       int ret = WEBRTC_ERROR_INVALID_OPERATION;
        webrtc_gst_slot_s *source;
        GstWebRTCRTPTransceiver *trans;
        GArray *transceivers;
@@ -1070,13 +1073,17 @@ int _set_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_
                        trans->direction = __direction_gst[direction];
                        LOG_DEBUG("Set direction to transceiver[%p, index:%d, mline:%u, direction:%s]",
                                trans, i, trans->mline, __direction_str[direction]);
-                       return WEBRTC_ERROR_NONE;
+                       ret = WEBRTC_ERROR_NONE;
+                       goto end;
                }
        }
 
        LOG_ERROR("could not find a transceiver with mline[%d]", mline);
 
-       return WEBRTC_ERROR_INVALID_OPERATION;
+end:
+       g_array_unref(transceivers);
+
+       return ret;
 }
 
 void _webrtcbin_on_negotiation_needed(GstElement *webrtcbin, gpointer user_data)