Fix crash in up_device_csr_finalize()

Spotted when running regression tests in KVM. There, initializing a HID device
causes a "could not initialize libusb: -99" warning, but the device is created
nevertheless. Do not crash in _finalize() by trying to call libusb_exit(NULL).
This commit is contained in:
Martin Pitt 2011-11-11 15:50:15 +01:00
parent d92aec6520
commit 46f1c7f028

View file

@ -323,7 +323,8 @@ up_device_csr_finalize (GObject *object)
csr = UP_DEVICE_CSR (object);
g_return_if_fail (csr->priv != NULL);
libusb_exit (csr->priv->ctx);
if (csr->priv->ctx != NULL);
libusb_exit (csr->priv->ctx);
if (csr->priv->poll_timer_id > 0)
g_source_remove (csr->priv->poll_timer_id);