[gnome-boxes/release-gnome-3-36-2: 1/10] Fix crash on creating a new box



commit 892d605780ba5c986fa8166fafdd047ce39ba4c2
Author: Sergio Costas <raster rastersoft com>
Date:   Sat Mar 28 15:37:00 2020 +0100

    Fix crash on creating a new box
    
    When choosing the option to create a new box, gnome-boxes crashes.
    In the terminal, a lot of 'Failed to find OS with id:...' messages
    are shown.
    
    After analyzing it, found that the problem is that it tries to
    fill three recommended downloads, but only two are available;
    all the others fail. Thus, when trying to fill the third, it
    crashes due to a NULL reference.
    
    This patch fixes this by ensuring that it will never try to show
    more than as many recommended OS are in the list. It also manages
    the case when all the list download fails and
    get_recommended_downloads() returns NULL.

 src/assistant/index-page.vala | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/assistant/index-page.vala b/src/assistant/index-page.vala
index 8587dd48..097220be 100644
--- a/src/assistant/index-page.vala
+++ b/src/assistant/index-page.vala
@@ -61,7 +61,9 @@ private async void populate_media_lists () {
         populate_detected_sources_list (MAX_MEDIA_ENTRIES);
 
         var recommended_downloads = yield get_recommended_downloads ();
-        for (var i = 0; i < MAX_MEDIA_ENTRIES; i++)
+        if (recommended_downloads == null)
+            return;
+        for (var i = 0; (i < recommended_downloads.length ()) && (i < MAX_MEDIA_ENTRIES); i++)
             featured_model.append (recommended_downloads.nth (i).data);
     }
 


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