[gnome-control-center/background-test-bg-name-not-null] background: Check for bg name before sorting wallpapers




commit a90de5743f57a058767735828dbde2c21ed0a31c
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon Oct 17 11:56:05 2022 +0200

    background: Check for bg name before sorting wallpapers
    
    Otherwise a missing <name> tag in an wallpaper XML can couse
    Settings to crash.
    
    Fixes #2087

 panels/background/bg-wallpapers-source.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c
index 42f70ba99..20ca4b77c 100644
--- a/panels/background/bg-wallpapers-source.c
+++ b/panels/background/bg-wallpapers-source.c
@@ -42,13 +42,18 @@ sort_func (gconstpointer a,
 {
   CcBackgroundItem *item_a;
   CcBackgroundItem *item_b;
+  const char *name_a;
+  const char *name_b;
 
   item_a = (CcBackgroundItem *) a;
   item_b = (CcBackgroundItem *) b;
 
-  if (strcmp (cc_background_item_get_name (item_a), "Default Background") == 0)
+  name_a = cc_background_item_get_name (item_a);
+  name_b = cc_background_item_get_name (item_b);
+
+  if (name_a && strcmp (name_a, "Default Background") == 0)
     return -1;
-  if (strcmp (cc_background_item_get_name (item_b), "Default Background") == 0)
+  if (name_b && strcmp (name_b, "Default Background") == 0)
     return 1;
 
 


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