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



commit eb00ac17a0ed522e3b7b7b42dbaac0b4f44a1ceb
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 c8d0e52..d0119fa 100644
--- a/src/plugins/appstream-cache.c
+++ b/src/plugins/appstream-cache.c
@@ -381,6 +381,7 @@ appstream_cache_add_item (AppstreamCacheHelper *helper)
        AppstreamAppIdKind id_kind;
        AppstreamCachePrivate *priv = helper->cache->priv;
        const gchar *id;
+       const gchar *pkgname;
 
        /* have we recorded this before? */
        id = appstream_app_get_id (helper->item_temp);
@@ -415,9 +416,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]