summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Manley <will@williammanley.net>2014-11-06 14:14:22 +0000
committerTim-Philipp Müller <tim@centricular.com>2014-11-09 14:58:32 +0000
commite243de82d75dc33d4a547b2cca6d65e7625c4267 (patch)
treedfa29b32765d100b03b92fb18a17376933d6bd2e
parent256f42f042db007af0651412facefccb2cfeca90 (diff)
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
-rw-r--r--gst/tcp/gstmultihandlesink.c4
-rw-r--r--gst/tcp/gsttcpserversink.c3
2 files changed, 7 insertions, 0 deletions
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 */