mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
tcp: Don't leak the resolver if name resolval failed
This commit is contained in:
parent
f98e647a31
commit
c2438ba868
4 changed files with 16 additions and 4 deletions
|
@ -282,6 +282,7 @@ gst_tcp_client_sink_start (GstBaseSink * bsink)
|
|||
GError *err = NULL;
|
||||
GInetAddress *addr;
|
||||
GSocketAddress *saddr;
|
||||
GResolver *resolver;
|
||||
|
||||
if (GST_OBJECT_FLAG_IS_SET (this, GST_TCP_CLIENT_SINK_OPEN))
|
||||
return TRUE;
|
||||
|
@ -300,9 +301,10 @@ gst_tcp_client_sink_start (GstBaseSink * bsink)
|
|||
/* look up name if we need to */
|
||||
addr = g_inet_address_new_from_string (this->host);
|
||||
if (!addr) {
|
||||
GResolver *resolver = g_resolver_get_default ();
|
||||
GList *results;
|
||||
|
||||
resolver = g_resolver_get_default ();
|
||||
|
||||
results =
|
||||
g_resolver_lookup_by_name (resolver, this->host, this->cancellable,
|
||||
&err);
|
||||
|
@ -351,6 +353,7 @@ name_resolve:
|
|||
("Failed to resolve host '%s': %s", this->host, err->message));
|
||||
}
|
||||
g_clear_error (&err);
|
||||
g_object_unref (resolver);
|
||||
gst_tcp_client_sink_stop (GST_BASE_SINK (this));
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -289,6 +289,7 @@ gst_tcp_client_src_start (GstBaseSrc * bsrc)
|
|||
GError *err = NULL;
|
||||
GInetAddress *addr;
|
||||
GSocketAddress *saddr;
|
||||
GResolver *resolver;
|
||||
|
||||
/* create receiving client socket */
|
||||
GST_DEBUG_OBJECT (src, "opening receiving client socket to %s:%d",
|
||||
|
@ -306,9 +307,10 @@ gst_tcp_client_src_start (GstBaseSrc * bsrc)
|
|||
/* look up name if we need to */
|
||||
addr = g_inet_address_new_from_string (src->host);
|
||||
if (!addr) {
|
||||
GResolver *resolver = g_resolver_get_default ();
|
||||
GList *results;
|
||||
|
||||
resolver = g_resolver_get_default ();
|
||||
|
||||
results =
|
||||
g_resolver_lookup_by_name (resolver, src->host, src->cancellable, &err);
|
||||
if (!results)
|
||||
|
@ -353,6 +355,7 @@ name_resolve:
|
|||
("Failed to resolve host '%s': %s", src->host, err->message));
|
||||
}
|
||||
g_clear_error (&err);
|
||||
g_object_unref (resolver);
|
||||
gst_tcp_client_src_stop (GST_BASE_SRC (src));
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -271,6 +271,7 @@ gst_tcp_server_sink_init_send (GstMultiSocketSink * parent)
|
|||
GError *err = NULL;
|
||||
GInetAddress *addr;
|
||||
GSocketAddress *saddr;
|
||||
GResolver *resolver;
|
||||
|
||||
/* create the server listener socket */
|
||||
this->server_socket =
|
||||
|
@ -285,9 +286,10 @@ gst_tcp_server_sink_init_send (GstMultiSocketSink * parent)
|
|||
/* look up name if we need to */
|
||||
addr = g_inet_address_new_from_string (this->host);
|
||||
if (!addr) {
|
||||
GResolver *resolver = g_resolver_get_default ();
|
||||
GList *results;
|
||||
|
||||
resolver = g_resolver_get_default ();
|
||||
|
||||
results =
|
||||
g_resolver_lookup_by_name (resolver, this->host,
|
||||
this->element.cancellable, &err);
|
||||
|
@ -353,6 +355,7 @@ name_resolve:
|
|||
("Failed to resolve host '%s': %s", this->host, err->message));
|
||||
}
|
||||
g_clear_error (&err);
|
||||
g_object_unref (resolver);
|
||||
gst_tcp_server_sink_close (&this->element);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -295,6 +295,7 @@ gst_tcp_server_src_start (GstBaseSrc * bsrc)
|
|||
GError *err = NULL;
|
||||
GInetAddress *addr;
|
||||
GSocketAddress *saddr;
|
||||
GResolver *resolver;
|
||||
|
||||
/* create the server listener socket */
|
||||
src->server_socket = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_STREAM,
|
||||
|
@ -307,9 +308,10 @@ gst_tcp_server_src_start (GstBaseSrc * bsrc)
|
|||
/* look up name if we need to */
|
||||
addr = g_inet_address_new_from_string (src->host);
|
||||
if (!addr) {
|
||||
GResolver *resolver = g_resolver_get_default ();
|
||||
GList *results;
|
||||
|
||||
resolver = g_resolver_get_default ();
|
||||
|
||||
results =
|
||||
g_resolver_lookup_by_name (resolver, src->host, src->cancellable, &err);
|
||||
if (!results)
|
||||
|
@ -362,6 +364,7 @@ name_resolve:
|
|||
("Failed to resolve host '%s': %s", src->host, err->message));
|
||||
}
|
||||
g_clear_error (&err);
|
||||
g_object_unref (resolver);
|
||||
gst_tcp_server_src_stop (GST_BASE_SRC (src));
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue