[gnome-software/gnome-3-20] plugin loader: Don't crash when refine fails in one plugin



commit 9dbdbba0cb08e914c9fe62ee69b94742139613f7
Author: Kalev Lember <klember redhat com>
Date:   Mon Jul 4 14:45:30 2016 +0200

    plugin loader: Don't crash when refine fails in one plugin
    
    When we iterate over plugins and ignore errors with the error_local
    pattern, make sure to also ignore return values, to avoid accidentally
    returning FALSE without an error set.

 src/gs-plugin-loader.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 012d619..c651a4a 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -173,11 +173,13 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                /* run the batched plugin symbol then the per-app plugin */
                if (plugin_func != NULL) {
                        g_autoptr(GError) error_local = NULL;
+                       gboolean ret_local;
+
                        g_rw_lock_reader_lock (&plugin->rwlock);
-                       ret = plugin_func (plugin, list, flags,
-                                          cancellable, &error_local);
+                       ret_local = plugin_func (plugin, list, flags,
+                                                cancellable, &error_local);
                        g_rw_lock_reader_unlock (&plugin->rwlock);
-                       if (!ret) {
+                       if (!ret_local) {
                                g_warning ("failed to call %s on %s: %s",
                                           function_name, plugin->name,
                                           error_local->message);
@@ -187,12 +189,14 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                if (plugin_app_func != NULL) {
                        for (l = *list; l != NULL; l = l->next) {
                                g_autoptr(GError) error_local = NULL;
+                               gboolean ret_local;
+
                                app = GS_APP (l->data);
                                g_rw_lock_reader_lock (&plugin->rwlock);
-                               ret = plugin_app_func (plugin, app, flags,
-                                                      cancellable, &error_local);
+                               ret_local = plugin_app_func (plugin, app, flags,
+                                                            cancellable, &error_local);
                                g_rw_lock_reader_unlock (&plugin->rwlock);
-                               if (!ret) {
+                               if (!ret_local) {
                                        g_warning ("failed to call %s on %s: %s",
                                                   function_name_app, plugin->name,
                                                   error_local->message);


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