From 5fa3fcf76ddd39eeb494911bfd78fb617885a56e Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Thu, 13 May 2021 22:25:55 -0400 Subject: [PATCH 1/2] rtspclientsink: Don't leak previous server_ip --- gst/rtsp-sink/gstrtspclientsink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gst/rtsp-sink/gstrtspclientsink.c b/gst/rtsp-sink/gstrtspclientsink.c index 96b6044b..7d0d90a3 100644 --- a/gst/rtsp-sink/gstrtspclientsink.c +++ b/gst/rtsp-sink/gstrtspclientsink.c @@ -3218,6 +3218,7 @@ gst_rtsp_client_sink_connect_to_server (GstRTSPClientSink * sink, sa = g_socket_get_remote_address (conn_socket, NULL); ia = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (sa)); + g_free (sink->server_ip); sink->server_ip = g_inet_address_to_string (ia); g_object_unref (sa); -- GitLab From 97e044ae49cc1a59d0cf21deb6d7b3b62b4d4da9 Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Thu, 13 May 2021 22:26:17 -0400 Subject: [PATCH 2/2] tests: Fix various leaks --- tests/check/gst/onvif.c | 42 +++++++++++++++++------------------- tests/check/gst/rtspserver.c | 3 +++ tests/check/gst/stream.c | 4 ++-- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/check/gst/onvif.c b/tests/check/gst/onvif.c index 087a2f79..637a7d59 100644 --- a/tests/check/gst/onvif.c +++ b/tests/check/gst/onvif.c @@ -35,7 +35,7 @@ typedef struct { GstPushSrc element; - GstSegment *segment; + GstSegment segment; /* In milliseconds */ guint trickmode_interval; GstClockTime ntp_offset; @@ -120,7 +120,7 @@ G_DEFINE_TYPE (TestSrc, test_src, GST_TYPE_PUSH_SRC); * When creating a buffer, we use the current segment position to * determine the PTS, and simply increment it afterwards. * - * When the stop time of a buffer we have created reaches segment->stop, + * When the stop time of a buffer we have created reaches segment.stop, * GstBaseSrc will take care of sending an EOS for us, which rtponviftimestamp * will translate to setting the T flag in the RTP header extension. */ @@ -134,29 +134,29 @@ test_src_create (GstPushSrc * psrc, GstBuffer ** buffer) FrameType ftype; guint64 n_frames; - if (src->segment->rate < 1.0) { - if (src->segment->position < src->segment->start) { + if (src->segment.rate < 1.0) { + if (src->segment.position < src->segment.start) { ret = GST_FLOW_EOS; goto done; } - } else if ((src->segment->position >= src->segment->stop)) { + } else if ((src->segment.position >= src->segment.stop)) { ret = GST_FLOW_EOS; goto done; } - pts = src->segment->position; + pts = src->segment.position; duration = FRAME_DURATION; - if ((src->segment->flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS)) { + if ((src->segment.flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS)) { duration = MAX (duration * 10, duration * ROUND_UP_TO_10 (src->trickmode_interval)); - } else if ((src->segment-> + } else if ((src->segment. flags & GST_SEGMENT_FLAG_TRICKMODE_FORWARD_PREDICTED)) { duration *= 5; } - n_frames = gst_util_uint64_scale (src->segment->position, 1000, GST_SECOND); + n_frames = gst_util_uint64_scale (src->segment.position, 1000, GST_SECOND); ftype = frame_type_for_index (n_frames); @@ -181,7 +181,7 @@ test_src_create (GstPushSrc * psrc, GstBuffer ** buffer) GST_BUFFER_PTS (*buffer) = pts; GST_BUFFER_DURATION (*buffer) = duration; - src->segment->position = pts + duration; + src->segment.position = pts + duration; if (!GST_CLOCK_TIME_IS_VALID (src->ntp_offset)) { GstClock *clock = gst_system_clock_obtain (); @@ -203,11 +203,11 @@ test_src_create (GstPushSrc * psrc, GstBuffer ** buffer) gst_element_send_event (GST_ELEMENT (src), onvif_event); } - if (src->segment->rate < 1.0) { + if (src->segment.rate < 1.0) { guint64 next_n_frames = - gst_util_uint64_scale (src->segment->position, 1000, GST_SECOND); + gst_util_uint64_scale (src->segment.position, 1000, GST_SECOND); - if (src->segment->position > src->segment->stop + if (src->segment.position > src->segment.stop || next_n_frames / 10 > n_frames / 10) { GstStructure *s; GstEvent *onvif_event; @@ -217,7 +217,7 @@ test_src_create (GstPushSrc * psrc, GstBuffer ** buffer) next_n_frames = (n_frames / 10 - n_gops) * 10; - src->segment->position = next_n_frames * GST_MSECOND; + src->segment.position = next_n_frames * GST_MSECOND; s = gst_structure_new ("GstNtpOffset", "ntp-offset", G_TYPE_UINT64, src->ntp_offset, "discont", G_TYPE_BOOLEAN, TRUE, NULL); @@ -237,7 +237,7 @@ test_src_init (TestSrc * src) { gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_automatic_eos (GST_BASE_SRC (src), FALSE); - src->segment = NULL; + gst_segment_init (&src->segment, GST_FORMAT_TIME); src->ntp_offset = GST_CLOCK_TIME_NONE; } @@ -269,17 +269,14 @@ test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment) segment->rate = segment->rate > 0 ? 1.0 : -1.0; } - if (src->segment) - gst_segment_free (src->segment); + gst_segment_copy_into (segment, &src->segment); - src->segment = gst_segment_copy (segment); - - if (src->segment->rate < 0) { + if (src->segment.rate < 0) { guint64 n_frames = - ROUND_DOWN_TO_10 (gst_util_uint64_scale (src->segment->stop, 1000, + ROUND_DOWN_TO_10 (gst_util_uint64_scale (src->segment.stop, 1000, GST_SECOND)); - src->segment->position = n_frames * GST_MSECOND; + src->segment.position = n_frames * GST_MSECOND; } return TRUE; @@ -457,6 +454,7 @@ test_response_x_onvif_track (GstRTSPClient * client, GstRTSPMessage * response, fail_unless_equals_string (gst_sdp_media_get_attribute_val (smedia, "x-onvif-track"), x_onvif_track); + g_free (x_onvif_track); } gst_sdp_message_free (sdp); diff --git a/tests/check/gst/rtspserver.c b/tests/check/gst/rtspserver.c index ed2cce23..7eed9010 100644 --- a/tests/check/gst/rtspserver.c +++ b/tests/check/gst/rtspserver.c @@ -2575,6 +2575,8 @@ GST_START_TEST (test_suspend_mode_reset_only_audio) session) == GST_RTSP_STS_OK); /* clean up and iterate so the clean-up can finish */ + g_object_unref (rtp_socket); + g_object_unref (rtcp_socket); g_free (session); gst_rtsp_transport_free (audio_transport); gst_sdp_message_free (sdp_message); @@ -2695,6 +2697,7 @@ GST_START_TEST (test_double_play) gst_rtsp_transport_free (audio_transport); gst_sdp_message_free (sdp_message); gst_rtsp_connection_free (conn); + g_object_unref (client); stop_server (); iterate (); diff --git a/tests/check/gst/stream.c b/tests/check/gst/stream.c index 3da4f9b2..b331d122 100644 --- a/tests/check/gst/stream.c +++ b/tests/check/gst/stream.c @@ -632,10 +632,10 @@ add_transports (gboolean add_twice) fail_if (gst_rtsp_stream_remove_transport (stream, tr)); } - fail_unless (gst_rtsp_transport_free (transport) == GST_RTSP_OK); fail_unless (gst_rtsp_stream_leave_bin (stream, bin, rtpbin)); gst_object_unref (bin); - gst_object_unref (stream); + g_object_unref (tr); + g_object_unref (stream); } -- GitLab