[gupnp] device-info: Add null-check in icon lookup



commit 8b8666e120a49a054904a35b5b8ec7686c53e84d
Author: Jens Georg <mail jensge org>
Date:   Thu May 26 11:15:53 2022 +0200

    device-info: Add null-check in icon lookup
    
    Basically to satisfy scan-build...

 libgupnp/gupnp-device-info.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/libgupnp/gupnp-device-info.c b/libgupnp/gupnp-device-info.c
index 9f8623c..389281b 100644
--- a/libgupnp/gupnp-device-info.c
+++ b/libgupnp/gupnp-device-info.c
@@ -908,7 +908,7 @@ gupnp_device_info_get_icon_url (GUPnPDeviceInfo *info,
                         icon = l->data;
 
                         /* Look between icons with positive weight first */
-                        if (icon->weight >= 0) {
+                        if (icon && icon->weight >= 0) {
                                 if (!closest || icon->weight < closest->weight)
                                         closest = icon;
                         }
@@ -921,7 +921,8 @@ gupnp_device_info_get_icon_url (GUPnPDeviceInfo *info,
 
                         /* No icons with positive weight, look at ones with
                          * negative weight */
-                        if (!closest || icon->weight > closest->weight)
+                        if (!closest ||
+                            (icon && (icon->weight > closest->weight)))
                                 closest = icon;
                 }
         }


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