webrtc: Fix memory leaks

Redundant condition and unreachable codes are also removed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1544>
This commit is contained in:
Sangchul Lee 2022-01-19 23:17:23 +09:00 committed by GStreamer Marge Bot
parent 107088a658
commit 5cedf017f5
3 changed files with 7 additions and 8 deletions

View file

@ -3352,7 +3352,7 @@ _create_offer_task (GstWebRTCBin * webrtc, const GstStructure * options,
reserved_pts = gather_reserved_pts (webrtc);
if (last_offer && _parse_bundle (last_offer, &last_bundle, NULL)
&& last_bundle && last_bundle && last_bundle[0]
&& last_bundle && last_bundle[0]
&& _get_bundle_index (last_offer, last_bundle, &bundle_media_index)) {
bundle_ufrag =
g_strdup (_media_get_ice_ufrag (last_offer, bundle_media_index));
@ -4746,6 +4746,7 @@ _set_rtx_ptmap_from_stream (GstWebRTCBin * webrtc, TransportStream * stream)
g_object_set (stream->rtxsend, "payload-type-map", pt_map, NULL);
gst_structure_free (pt_map);
g_free (rtx_pt);
}
}
@ -6482,7 +6483,6 @@ on_rtpbin_request_aux_sender (GstElement * rtpbin, guint session_id,
{
TransportStream *stream;
gboolean have_rtx = FALSE;
GstStructure *pt_map = NULL;
GstElement *ret = NULL;
stream = _find_transport_for_session (webrtc, session_id);
@ -6490,8 +6490,8 @@ on_rtpbin_request_aux_sender (GstElement * rtpbin, guint session_id,
if (stream)
have_rtx = transport_stream_get_pt (stream, "RTX", -1) != 0;
GST_LOG_OBJECT (webrtc, "requesting aux sender for stream %" GST_PTR_FORMAT
" with pt map %" GST_PTR_FORMAT, stream, pt_map);
GST_LOG_OBJECT (webrtc, "requesting aux sender for stream %" GST_PTR_FORMAT,
stream);
if (have_rtx) {
GstElement *rtx;
@ -6543,9 +6543,6 @@ on_rtpbin_request_aux_sender (GstElement * rtpbin, guint session_id,
}
out:
if (pt_map)
gst_structure_free (pt_map);
return ret;
}

View file

@ -822,7 +822,7 @@ webrtc_data_channel_send_string (GstWebRTCDataChannel * base_channel,
ppid = DATA_CHANNEL_PPID_WEBRTC_STRING_EMPTY;
} else {
gsize size = strlen (str);
gchar *str_copy = g_strdup (str);
gchar *str_copy;
if (!_is_within_max_message_size (channel, size)) {
GError *error = NULL;
@ -835,6 +835,7 @@ webrtc_data_channel_send_string (GstWebRTCDataChannel * base_channel,
return;
}
str_copy = g_strdup (str);
buffer =
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, str_copy,
size, 0, size, str_copy, g_free);

View file

@ -569,6 +569,7 @@ _media_replace_setup (GstSDPMedia * media, GstWebRTCDTLSSetup setup)
GST_TRACE ("replace setup:%s with setup:%s", attr->value, setup_str);
gst_sdp_attribute_set (&new_attr, "setup", setup_str);
gst_sdp_media_replace_attribute (media, i, &new_attr);
g_free (setup_str);
return;
}
}