Darwin: fix crash when reading descriptors after close
authorNathan Hjelm <hjelmn@mac.com>
Sun, 23 Aug 2009 04:17:55 +0000 (10:02 +0545)
committerDaniel Drake <dsd@gentoo.org>
Sun, 23 Aug 2009 04:17:55 +0000 (10:02 +0545)
Fix a crash which occurs if the user does the following sequence on a
device: open, close, get_configuration_descriptor.

libusb/os/darwin_usb.c

index 9e12e07..8c1afec 100644 (file)
@@ -652,6 +652,9 @@ static void darwin_close (struct libusb_device_handle *dev_handle) {
   usbi_remove_pollfd (HANDLE_CTX (dev_handle), priv->fds[0]);
   close (priv->fds[1]);
   close (priv->fds[0]);
+
+  dpriv->device = NULL;
+  priv->fds[0] = priv->fds[1] = -1;
 }
 
 static int darwin_get_configuration(struct libusb_device_handle *dev_handle, int *config) {