[gnome-software/gnome-3-22] trivial: Fix a crash when unloading all plugins



commit 5ade8429a172fadce0cc53404f83855609b3b511
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 23 14:50:39 2017 +0000

    trivial: Fix a crash when unloading all plugins
    
    In appstream-glib the category list is expected to be an array of AsRefString
    rather than gchar*, so when we add the blacklist entries to the *same*
    GPtrArray in another plugin we do an 'Invalid read of size 4' when we unref the
    array in the library.
    
    To fix just add each category manually, although it does require copying the
    string. If/when we use AsRefString in gnome-software we can revert this.

 src/plugins/gs-appstream.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 1cc3713..01731d7 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -535,6 +535,7 @@ gs_appstream_refine_app (GsPlugin *plugin,
        AsRequire *req;
        g_autoptr(GError) error_local = NULL;
        GHashTable *urls;
+       GPtrArray *array;
        GPtrArray *pkgnames;
        GPtrArray *kudos;
        const gchar *tmp;
@@ -687,9 +688,13 @@ gs_appstream_refine_app (GsPlugin *plugin,
                gs_refine_item_icon (plugin, app, item);
 
        /* set categories */
-       if (as_app_get_categories (item) != NULL &&
-           gs_app_get_categories (app)->len == 0)
-               gs_app_set_categories (app, as_app_get_categories (item));
+       array = as_app_get_categories (item);
+       if (array != NULL && gs_app_get_categories (app)->len == 0) {
+               for (i = 0; i < array->len; i++) {
+                       tmp = g_ptr_array_index (array, i);
+                       gs_app_add_category (app, tmp);
+               }
+       }
 
        /* set project group */
        if (as_app_get_project_group (item) != NULL &&


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