From e243de82d75dc33d4a547b2cca6d65e7625c4267 Mon Sep 17 00:00:00 2001 From: William Manley Date: Thu, 6 Nov 2014 14:14:22 +0000 Subject: tcpserversink: Don't leak a `GSocket` and a `GInetSocketAddress` when accepting a connection. Discovered by `make check-valgrind` with the new `socketintegrationtest`. https://bugzilla.gnome.org/show_bug.cgi?id=739544 --- gst/tcp/gstmultihandlesink.c | 4 ++++ gst/tcp/gsttcpserversink.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/gst/tcp/gstmultihandlesink.c b/gst/tcp/gstmultihandlesink.c index b9ba36b39..aa1cfb299 100644 --- a/gst/tcp/gstmultihandlesink.c +++ b/gst/tcp/gstmultihandlesink.c @@ -677,6 +677,10 @@ gst_multi_handle_sink_add_full (GstMultiHandleSink * sink, if (clink != NULL) goto duplicate; + /* We do not take ownership of @handle in this function, but we can't take a + * reference directly as we don't know the concrete type of the handle. + * GstMultiHandleSink relies on the derived class to take a reference for us + * in new_client: */ mhclient = mhsinkclass->new_client (mhsink, handle, sync_method); /* we can add the handle now */ diff --git a/gst/tcp/gsttcpserversink.c b/gst/tcp/gsttcpserversink.c index 244b5764f..b805ebc40 100644 --- a/gst/tcp/gsttcpserversink.c +++ b/gst/tcp/gsttcpserversink.c @@ -163,6 +163,7 @@ gst_tcp_server_sink_handle_server_read (GstTCPServerSink * sink) goto accept_failed; handle.socket = client_socket; + /* gst_multi_handle_sink_add does not take ownership of client_socket */ gst_multi_handle_sink_add (GST_MULTI_HANDLE_SINK (sink), handle); #ifndef GST_DISABLE_GST_DEBUG @@ -177,9 +178,11 @@ gst_tcp_server_sink_handle_server_read (GstTCPServerSink * sink) ip, g_inet_socket_address_get_port (addr), client_socket); g_free (ip); + g_object_unref (addr); } #endif + g_object_unref (client_socket); return TRUE; /* ERRORS */ -- cgit v1.2.3