Commit 2be6abe9 authored by Philip Withnall's avatar Philip Withnall Committed by Philip Withnall

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
parent 73aae8bb
...@@ -860,6 +860,10 @@ gnutls_source_sync (GTlsConnectionGnutlsSource *gnutls_source) ...@@ -860,6 +860,10 @@ gnutls_source_sync (GTlsConnectionGnutlsSource *gnutls_source)
GTlsConnectionGnutls *gnutls = gnutls_source->gnutls; GTlsConnectionGnutls *gnutls = gnutls_source->gnutls;
gboolean io_waiting, op_waiting; 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); g_mutex_lock (&gnutls->priv->op_mutex);
if (((gnutls_source->condition & G_IO_IN) && gnutls->priv->reading) || if (((gnutls_source->condition & G_IO_IN) && gnutls->priv->reading) ||
((gnutls_source->condition & G_IO_OUT) && gnutls->priv->writing) || ((gnutls_source->condition & G_IO_OUT) && gnutls->priv->writing) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment