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



commit e6a866d9b32850ab2d7590552918c4305b8d042e
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 |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index e55fe6c..9eec899 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -702,9 +702,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]