[glib-networking/wip/pwithnall/dtls: 9/21] gnutls: Fix leaking GTask on TLS close after implicit handshake
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/wip/pwithnall/dtls: 9/21] gnutls: Fix leaking GTask on TLS close after implicit handshake
- Date: Mon, 9 Nov 2015 12:37:28 +0000 (UTC)
commit 0cb8d43cf065d8fefb6a37c6ba88b08ae10c81de
Author: Philip Withnall <philip withnall collabora co uk>
Date: Wed Sep 17 13:13:06 2014 +0100
gnutls: Fix leaking GTask on TLS close after implicit handshake
If a GTlsConnectionGnutls is created and an implicit handshake operation
is started on it (e.g. via a read), if the handshake doesn’t complete
and close() is called on the connection without any other operations
being called first, the GTlsConnectionGnutls.implicit_handshake GTask
will be leaked. Since it holds a reference to the GTlsConnectionGnutls
connection as a whole, that object will be leaked too in a reference
cycle.
Fix this by explicitly clearing implicit_handshake when claiming
OP_CLOSE, instead of ignoring it. Any errors from the handshake process
are ignored as before, however.
https://bugzilla.gnome.org/show_bug.cgi?id=736809
tls/gnutls/gtlsconnection-gnutls.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 439d4d5..5f06233 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -585,10 +585,10 @@ claim_op (GTlsConnectionGnutls *gnutls,
return FALSE;
}
- if (op != G_TLS_CONNECTION_GNUTLS_OP_HANDSHAKE &&
- op != G_TLS_CONNECTION_GNUTLS_OP_CLOSE)
+ if (op != G_TLS_CONNECTION_GNUTLS_OP_HANDSHAKE)
{
- if (gnutls->priv->need_handshake)
+ if (op != G_TLS_CONNECTION_GNUTLS_OP_CLOSE &&
+ gnutls->priv->need_handshake)
{
gnutls->priv->need_handshake = FALSE;
gnutls->priv->handshaking = TRUE;
@@ -612,12 +612,15 @@ claim_op (GTlsConnectionGnutls *gnutls,
g_clear_object (&gnutls->priv->implicit_handshake);
g_mutex_lock (&gnutls->priv->op_mutex);
- if (!success || g_cancellable_set_error_if_cancelled (cancellable, &my_error))
+ if (op != G_TLS_CONNECTION_GNUTLS_OP_CLOSE &&
+ (!success || g_cancellable_set_error_if_cancelled (cancellable, &my_error)))
{
g_propagate_error (error, my_error);
g_mutex_unlock (&gnutls->priv->op_mutex);
return FALSE;
}
+
+ g_clear_error (&my_error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]