OpenKinect / libfreenect2

Open source drivers for the Kinect for Windows v2 device
2.05k stars 747 forks source link

the devices needs to be unref, or less libusb --HEAD complains and/or crashes #1169

Open timprepscius opened 2 years ago

timprepscius commented 2 years ago
              if(r > LIBUSB_SUCCESS)
              {
                UsbDeviceWithSerial dev_with_serial;
                dev_with_serial.dev = dev;
                dev_with_serial.serial = std::string(reinterpret_cast<char *>(buffer), size_t(r));

                LOG_INFO << "found valid Kinect v2 " << PrintBusAndDevice(dev) << " with serial " << dev_with_serial.serial;
                // valid Kinect v2
                enumerated_devices_.push_back(dev_with_serial);
                continue;
              }
              else
              {
                libusb_unref_device(dev);
                LOG_ERROR << "failed to get serial number of Kinect v2: " << PrintBusAndDevice(dev, r);
              }

The "continue" found on line: 548 should not be there

because the: libusb_unref_device(dev); on line 563 needs to run

else there is a dangling reference and libusb > 1.0.25 asserts or >= 1.0.26 crashes