Darwin: Fix a SIGFPE
authorBei Zhang <ikarienator@gmail.com>
Fri, 23 Aug 2013 08:10:35 +0000 (01:10 -0700)
committerPete Batard <pete@akeo.ie>
Tue, 7 Jan 2014 21:12:25 +0000 (21:12 +0000)
* GetPipeProperties() may fail when the device is unplugged if DeviceVersion is not greater than 320.
* In this case maxPacketSize will be zero and the integer division will throw a EXC_ARITHMETIC signal.
* Closes #136

libusb/os/darwin_usb.c
libusb/version_nano.h

index 0105e3c..146218b 100644 (file)
@@ -1445,8 +1445,14 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
 
   cInterface = &priv->interfaces[iface];
 
-  (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
-                                                 &transferType, &maxPacketSize, &interval);
+  ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
+                                                       &transferType, &maxPacketSize, &interval);
+
+  if (ret) {
+    usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out",
+              darwin_error_str(ret), ret);
+    return darwin_to_libusb (ret);
+  }
 
   if (0 != (transfer->length % maxPacketSize)) {
     /* do not need a zero packet */
index d576271..6d6aaaa 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10858
+#define LIBUSB_NANO 10859