[gnome-software/1699-crash-under-gs_plugin_flatpak_find_app_by_ref] gs-app-list: Randomize non-empty lists only



commit ee2640168d906cd3195283a487a494082d19a08e
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 20 21:17:56 2022 +0200

    gs-app-list: Randomize non-empty lists only
    
    It avoids a crash with a NULL-dereference. Had been spotted when
    testing https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1699 .

 lib/gs-app-list.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/lib/gs-app-list.c b/lib/gs-app-list.c
index 12ad55f3d..a5f67858b 100644
--- a/lib/gs-app-list.c
+++ b/lib/gs-app-list.c
@@ -718,6 +718,9 @@ gs_app_list_randomize (GsAppList *list)
 
        locker = g_mutex_locker_new (&list->mutex);
 
+       if (!gs_app_list_length (list))
+               return;
+
        rand = g_rand_new ();
        date = g_date_time_new_now_utc ();
        g_rand_set_seed (rand, (guint32) g_date_time_get_day_of_year (date));


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