[gnome-software/wip/show-metainfo-fixes] gs-app: Verify an icon was loaded in calculate_key_colors()



commit f1c1829bf97d743f556bd7bd2887f71a827a9f8b
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 4 16:16:10 2022 +0200

    gs-app: Verify an icon was loaded in calculate_key_colors()
    
    The icon_stream is NULL when the icon could not be loaded,
    which leads to a runtime warning when passing it into
    gdk_pixbuf_new_from_stream_at_scale(), thus make sure
    a valid object is passed to the function.

 lib/gs-app.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 8d323b234..373f844d6 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -4650,7 +4650,8 @@ calculate_key_colors (GsApp *app)
                return;
        } else if (G_IS_LOADABLE_ICON (icon_small)) {
                g_autoptr(GInputStream) icon_stream = g_loadable_icon_load (G_LOADABLE_ICON (icon_small), 32, 
NULL, NULL, NULL);
-               pb_small = gdk_pixbuf_new_from_stream_at_scale (icon_stream, 32, 32, TRUE, NULL, NULL);
+               if (icon_stream)
+                       pb_small = gdk_pixbuf_new_from_stream_at_scale (icon_stream, 32, 32, TRUE, NULL, 
NULL);
        } else if (G_IS_THEMED_ICON (icon_small)) {
                g_autoptr(GtkIconPaintable) icon_paintable = NULL;
                g_autoptr(GtkIconTheme) theme = NULL;


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