diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-04-23 12:16:02 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-04-24 09:25:46 +0200 |
commit | ddeec68a4d9a36589a3722845e260602a4204cb6 (patch) | |
tree | 6a76cdee84a43056bce2451074ced22b5ab28a51 | |
parent | f90b107c0cece52c15f55d32673351e3188ff3f1 (diff) |
usb-device-manager: Error check spice_usb_device_manager_device_to_libdev calls
Under Windows all calls to spice_usb_device_manager_device_to_libdev may fail,
so error check them all.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | gtk/usb-device-manager.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c index 76f82b2..dc334bd 100644 --- a/gtk/usb-device-manager.c +++ b/gtk/usb-device-manager.c @@ -1090,7 +1090,10 @@ static void spice_usb_device_manager_check_redir_on_connect( continue; libdev = spice_usb_device_manager_device_to_libdev(self, device); - +#ifdef G_OS_WIN32 + if (libdev == NULL) + continue; +#endif if (usbredirhost_check_device_filter( priv->redirect_on_connect_rules, priv->redirect_on_connect_rules_count, @@ -1448,7 +1451,13 @@ spice_usb_device_manager_can_redirect_device(SpiceUsbDeviceManager *self, libusb_device *libdev; libdev = spice_usb_device_manager_device_to_libdev(self, device); - g_return_val_if_fail(libdev != NULL, FALSE); +#ifdef G_OS_WIN32 + if (libdev == NULL) { + g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, + _("Some USB devices were not found")); + return FALSE; + } +#endif filter_ok = (usbredirhost_check_device_filter( guest_filter_rules, guest_filter_rules_count, libdev, 0) == 0); |