[gupnp/gupnp-1.0] Avoid a crash in GUPnPServiceProxy::subscription_expire()



commit 2759f3f33629c1b1abd9e7684479a3158fcd1a1d
Author: Sven Neumann <neumann teufel de>
Date:   Thu Mar 30 09:51:17 2017 +0200

    Avoid a crash in GUPnPServiceProxy::subscription_expire()
    
    Can't explain why, but we are seeing crashes in subscription_expire()
    that seem to be caused by an attempt to renew the subscription even
    though the SID is not set, leading to a crash in
    soup_message_headers_append().
    
    Add an extra check in subscription_expire() and also make sure
    that the subscription timeout is removed before a new timeout is
    installed in subscription_response().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780715
    
    Signed-off-by: Sven Neumann <neumann teufel de>

 libgupnp/gupnp-service-proxy.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index 363c8c9..2e693ce 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -2246,6 +2246,8 @@ subscription_expire (gpointer user_data)
         /* Reset timeout ID */
         proxy->priv->subscription_timeout_src = NULL;
 
+        g_return_val_if_fail (proxy->priv->sid != NULL, FALSE);
+
         /* Send renewal message */
         context = gupnp_service_info_get_context (GUPNP_SERVICE_INFO (proxy));
 
@@ -2303,6 +2305,12 @@ subscribe_got_response (G_GNUC_UNUSED SoupSession *session,
         proxy->priv->pending_messages =
                 g_list_remove (proxy->priv->pending_messages, msg);
 
+        /* Remove subscription timeout */
+        if (proxy->priv->subscription_timeout_src) {
+                g_source_destroy (proxy->priv->subscription_timeout_src);
+                proxy->priv->subscription_timeout_src = NULL;
+        }
+
         /* Check whether the subscription is still wanted */
         if (!proxy->priv->subscribed)
                 return;


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