[gnome-settings-daemon/gnome-3-6] updates: Fix crasher when firmware updates is disabled



commit 15371fa1741eb409302398962a0c4ca04cee4a68
Author: Elliott Sales de Andrade <quantum analyst gmail com>
Date:   Mon Feb 18 22:28:00 2013 +0000

    updates: Fix crasher when firmware updates is disabled
    
    g_ptr_array_remove_index_fast() was called as well as a free
    function, but the GPtrArray already had its own free function.
    
    Furthermore, g_ptr_array_remove_index_fast() replaces the
    indexed element with the last element, which means the current index
    must still be checked, but the for loop skipped it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694129

 plugins/updates/gsd-updates-firmware.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/plugins/updates/gsd-updates-firmware.c b/plugins/updates/gsd-updates-firmware.c
index dc972a5..531f04d 100644
--- a/plugins/updates/gsd-updates-firmware.c
+++ b/plugins/updates/gsd-updates-firmware.c
@@ -647,18 +647,21 @@ remove_banned (GsdUpdatesFirmware *firmware, GPtrArray *array)
         banned = g_strsplit (banned_str, ",", 0);
 
         /* remove any banned pattern matches */
-        for (i=0; i<array->len; i++) {
+        i = 0;
+        while (i < array->len) {
+                ret = FALSE;
                 req = g_ptr_array_index (array, i);
                 for (j=0; banned[j] != NULL; j++) {
                         ret = g_pattern_match_simple (banned[j], req->filename);
                         if (ret) {
                                 g_debug ("match %s for %s, removing",
                                          banned[j], req->filename);
-                                request_free (req);
                                 g_ptr_array_remove_index_fast (array, i);
                                 break;
                         }
                 }
+                if (!ret)
+                        i++;
         }
 out:
         g_free (banned_str);
@@ -692,7 +695,9 @@ remove_ignored (GsdUpdatesFirmware *firmware, GPtrArray *array)
         ignored = g_strsplit (ignored_str, ",", 0);
 
         /* remove any ignored pattern matches */
-        for (i=0; i<array->len; i++) {
+        i = 0;
+        while (i < array->len) {
+                ret = FALSE;
                 req = g_ptr_array_index (array, i);
                 if (req->id == NULL)
                         continue;
@@ -700,11 +705,12 @@ remove_ignored (GsdUpdatesFirmware *firmware, GPtrArray *array)
                         ret = g_pattern_match_simple (ignored[j], req->id);
                         if (ret) {
                                 g_debug ("match %s for %s, removing", ignored[j], req->id);
-                                request_free (req);
                                 g_ptr_array_remove_index_fast (array, i);
                                 break;
                         }
                 }
+                if (!ret)
+                        i++;
         }
 out:
         g_free (ignored_str);


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