[gnome-boxes] Fix crash on creating a new box



commit 775f1b0e385c21ba0d58de61b46b5018ffa0d375
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 b3e82b6f..dccdd022 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]