[Spice-devel] [spice-gtk v1 5/5] channel-usbredir: handle failure from SpiceUsbDeviceManager
Victor Toso
victortoso at redhat.com
Mon Nov 14 23:26:55 UTC 2016
From: Victor Toso <me at victortoso.com>
As spice_usb_device_manager_get() can be NULL
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
src/channel-usbredir.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index add7d5e..4837d68 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -293,6 +293,7 @@ static gboolean spice_usbredir_channel_open_device(
SpiceSession *session;
libusb_device_handle *handle = NULL;
int rc, status;
+ SpiceUsbDeviceManager *manager;
g_return_val_if_fail(priv->state == STATE_DISCONNECTED
#ifdef USE_POLKIT
@@ -317,7 +318,10 @@ static gboolean spice_usbredir_channel_open_device(
}
session = spice_channel_get_session(SPICE_CHANNEL(channel));
- priv->usb_device_manager = g_object_ref(spice_usb_device_manager_get(session, NULL));
+ manager = spice_usb_device_manager_get(session, NULL);
+ g_return_val_if_fail(manager != NULL, FALSE);
+
+ priv->usb_device_manager = g_object_ref(manager);
if (!spice_usb_device_manager_start_event_listening(priv->usb_device_manager, err)) {
usbredirhost_set_device(priv->host, NULL);
return FALSE;
--
2.9.3
More information about the Spice-devel
mailing list