[spice-gtk v1] usb-device-widget: Fix crash on no USB devices

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

 



From: goldengdeng <907246009@xxxxxx>

The spice_usb_device_manager_get_devices() is only checking for NULL
while the program can crash when no USB devices are available.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/usb-device-widget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index a3c0910..0384d14 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -218,7 +218,7 @@ static void spice_usb_device_widget_constructed(GObject *gobject)
                      G_CALLBACK(device_error_cb), self);
 
     devices = spice_usb_device_manager_get_devices(priv->manager);
-    if (!devices)
+    if (devices->len == 0)
         goto end;
 
     for (i = 0; i < devices->len; i++)
-- 
2.16.2

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]