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



commit 0246972ec60d8f40461e90ebf6df977dee38ca7b
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 49e948d..8a7ad2a 100644
--- a/plugins/updates/gsd-updates-firmware.c
+++ b/plugins/updates/gsd-updates-firmware.c
@@ -651,18 +651,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);
@@ -696,7 +699,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;
@@ -704,11 +709,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]