[gnome-software/gnome-3-10] Do not crash if the AppData metadata does not have <pkgname>



commit 774bff3a97a013052a1d95f1935aca26d45645d2
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 17 20:20:16 2013 +0100

    Do not crash if the AppData metadata does not have <pkgname>

 src/plugins/appstream-cache.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/appstream-cache.c b/src/plugins/appstream-cache.c
index d304641..a9a3af0 100644
--- a/src/plugins/appstream-cache.c
+++ b/src/plugins/appstream-cache.c
@@ -343,6 +343,7 @@ appstream_cache_add_item (AppstreamCacheHelper *helper)
        AppstreamApp *item;
        AppstreamCachePrivate *priv = helper->cache->priv;
        const gchar *id;
+       const gchar *pkgname;
 
        /* is app compatible with this running desktop */
        id = appstream_app_get_id (helper->item_temp);
@@ -365,9 +366,12 @@ appstream_cache_add_item (AppstreamCacheHelper *helper)
        g_hash_table_insert (priv->hash_id,
                             (gpointer) appstream_app_get_id (helper->item_temp),
                             helper->item_temp);
-       g_hash_table_insert (priv->hash_pkgname,
-                            (gpointer) appstream_app_get_pkgname (helper->item_temp),
-                            helper->item_temp);
+       pkgname = appstream_app_get_pkgname (helper->item_temp);
+       if (pkgname != NULL) {
+               g_hash_table_insert (priv->hash_pkgname,
+                                    (gpointer) pkgname,
+                                    helper->item_temp);
+       }
 }
 
 /**


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