[glib-networking] gnutls: Prevent use of a destroyed GSource in a callback



commit 2be6abe961294bfe893ea47f2b41ebb2894ca8a2
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Feb 6 15:32:51 2014 +0000

    gnutls: Prevent use of a destroyed GSource in a callback
    
    It’s possible for the GTlsConnectionGnutlsSource to be destroyed in its
    user-provided callback function. If gnutls_source_sync() is called after
    this, it ends up attempting to modify the GSource after it’s been
    destroyed, which is disallowed.
    
    Bail out of gnutls_source_sync() early if the source has already been
    destroyed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723774

 tls/gnutls/gtlsconnection-gnutls.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index f1a99b3..f906f0b 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -860,6 +860,10 @@ gnutls_source_sync (GTlsConnectionGnutlsSource *gnutls_source)
   GTlsConnectionGnutls *gnutls = gnutls_source->gnutls;
   gboolean io_waiting, op_waiting;
 
+  /* Was the source destroyed earlier in this main context iteration? */
+  if (g_source_is_destroyed ((GSource *) gnutls_source))
+    return;
+
   g_mutex_lock (&gnutls->priv->op_mutex);
   if (((gnutls_source->condition & G_IO_IN) && gnutls->priv->reading) ||
       ((gnutls_source->condition & G_IO_OUT) && gnutls->priv->writing) ||


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]