[gssdp] Correctly remove expired Resources



commit 15da2add9330a4f60c526f1322080d19e7a0d0c9
Author: Mark Ryan <mark d ryan intel com>
Date:   Fri Aug 17 13:51:29 2012 +0200

    Correctly remove expired Resources
    
    Fixes a crash in GUPnP.  In the current code, Resource objects are not
    always correctly removed from the resource_browser->priv->resources
    hash table when they expire.  This can lead to a crash in GUPnP when
    the application tries to destroy its context manager.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682099

 libgssdp/gssdp-resource-browser.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/libgssdp/gssdp-resource-browser.c b/libgssdp/gssdp-resource-browser.c
index d68ca8b..f80de4a 100644
--- a/libgssdp/gssdp-resource-browser.c
+++ b/libgssdp/gssdp-resource-browser.c
@@ -591,6 +591,7 @@ resource_expire (gpointer user_data)
         GSSDPResourceBrowser *resource_browser;
         Resource *resource;
         char *usn;
+        char *canonical_usn;
 
         resource = user_data;
         resource_browser = resource->resource_browser;
@@ -601,13 +602,24 @@ resource_expire (gpointer user_data)
         usn = resource->usn;
         resource->usn = NULL;
 
-        g_hash_table_remove (resource->resource_browser->priv->resources, usn);
+        if (resource_browser->priv->version > 0) {
+                char *version;
+
+                version = g_strrstr (usn, ":");
+                canonical_usn = g_strndup (usn, version - usn);
+        } else {
+                canonical_usn = g_strdup (usn);
+        }
+
+        g_hash_table_remove (resource->resource_browser->priv->resources,
+                             canonical_usn);
 
         g_signal_emit (resource_browser,
                        signals[RESOURCE_UNAVAILABLE],
                        0,
                        usn);
         g_free (usn);
+        g_free (canonical_usn);
 
         return FALSE;
 }



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