After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 787306 - rtsp-sink : Fix Memory leak in gstrtspclientsink.c
rtsp-sink : Fix Memory leak in gstrtspclientsink.c
Status: RESOLVED INCOMPLETE
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
1.12.2
Other Windows
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-05 11:32 UTC by Satya Prakash Gupta
Modified: 2018-04-12 18:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch file is attached. (1004 bytes, patch)
2017-09-05 11:32 UTC, Satya Prakash Gupta
needs-work Details | Review
Updated patch is attached. (1.11 KB, patch)
2017-09-06 08:31 UTC, Satya Prakash Gupta
needs-work Details | Review
Updated patch is attached. (1.11 KB, patch)
2017-09-06 09:08 UTC, Satya Prakash Gupta
reviewed Details | Review
Patch file is updated. (1.08 KB, patch)
2017-09-06 10:06 UTC, Satya Prakash Gupta
needs-work Details | Review

Description Satya Prakash Gupta 2017-09-05 11:32:36 UTC
Created attachment 359174 [details] [review]
Patch file is attached.

Hi , 

  There is memory leak in gstrtspclientsink.c. Below is observation 

Function  gst_rtsp_client_sink_setup_streams  Line : 3731

There is memory leak in gstrtspclientsink.c file as "transport->destination = g_strdup (sink->server_ip);" but did not free the "detination ptr"


Solution :  g_free (transport->destination);

++patch is attched for possible solution.
Kindly review the patch and provide your feedback.
Comment 1 Sebastian Dröge (slomo) 2017-09-05 11:51:19 UTC
Review of attachment 359174 [details] [review]:

::: gst/rtsp-sink/gstrtspclientsink.c
@@ +3765,1 @@
         gst_rtsp_transport_free (transport);

gst_rtsp_transport_free() should free all memory related to the transport, so also that string
Comment 2 Satya Prakash Gupta 2017-09-05 11:55:26 UTC
Yes .. I am agree with it.
as per below doc
https://sourcecodebrowser.com/gst-plugins-base0.10/0.10.18/gstrtsptransport_8c_source.html
Comment 3 Sebastian Dröge (slomo) 2017-09-05 12:06:36 UTC
That's docs for a 10 year old version of the code.

In any case, please fix the free() function instead :)
Comment 4 Satya Prakash Gupta 2017-09-05 12:17:11 UTC
Does it means I need to write my free() function ..instead of of using  gst_rtsp_transport_free (transport);
Comment 5 Sebastian Dröge (slomo) 2017-09-05 12:45:04 UTC
No, you fix gst_rtsp_transport_free(). It's supposed to free everything
Comment 6 Satya Prakash Gupta 2017-09-06 08:31:34 UTC
Created attachment 359254 [details] [review]
Updated patch is attached.
Comment 7 Sebastian Dröge (slomo) 2017-09-06 08:49:04 UTC
Review of attachment 359254 [details] [review]:

::: gst/rtsp-sink/gstrtspclientsink.c
@@ -3760,1 @@
         gst_rtsp_stream_transport_set_active (context->stream_transport, TRUE);

This suggests that there is a bug in the stream_transport then. If it is suppsed to own the transport, it should also free it later when needed
Comment 8 Satya Prakash Gupta 2017-09-06 09:08:27 UTC
Created attachment 359255 [details] [review]
Updated patch is attached.

Please review the attached patch and provide your feedback.
Comment 9 Sebastian Dröge (slomo) 2017-09-06 09:32:44 UTC
Review of attachment 359255 [details] [review]:

::: gst/rtsp-sink/gstrtspclientsink.c
@@ -3758,3 @@
-        transport = NULL;
-
-        gst_rtsp_stream_transport_set_active (context->stream_transport, TRUE);

Why do you think removing this code is correct?
Comment 10 Satya Prakash Gupta 2017-09-06 10:06:43 UTC
Created attachment 359256 [details] [review]
Patch file is updated.

As per doc "void gst_rtsp_stream_transport_set_transport
                               (GstRTSPStreamTransport *trans,
                                GstRTSPTransport *tr);"
								
Set tr as the client transport. This function takes ownership of the passed tr .


But gst_rtsp_stream_transport_set_active does not take any ownership to transport . So I added updated code for it.

Please review once and provide your valuable comments.
Comment 11 Sebastian Dröge (slomo) 2017-09-07 10:00:02 UTC
Review of attachment 359256 [details] [review]:

::: gst/rtsp-sink/gstrtspclientsink.c
@@ +3762,3 @@
+              TRUE);
+          gst_object_unref (context->stream_transport);
+          context->stream_transport = NULL;

This makes no sense:
a) context->stream_transport is always not NULL here
b) You first activate the stream transport, then unref and set it to NULL. Basically destroying the stream transport right after activating it

Do you have a testcase to reproduce this memory leak? I would expect that test case to fail in worse ways than a memory leak with that patch.

Also you said that the transport (not stream_transport) is leaked, or rather the string inside it. That would have to be freed as part of the transport then.
Comment 12 Tim-Philipp Müller 2018-04-12 18:03:11 UTC
Can't do more here without more detailed information, sorry.

Please also re-test with the latest release, a lot of code was refactored, thanks.