Skip to content

Commit

Permalink
Verify USB listener callback handle
Browse files Browse the repository at this point in the history
Do not use `handle` if `libusb_hotplug_register_callback` fails
  • Loading branch information
sizeofvoid authored and pull[bot] committed Jun 23, 2024
1 parent 266c025 commit a1ddb45
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/gui/osutils/nixutils/DeviceListenerLibUsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ DeviceListenerLibUsb::registerHotplugCallback(bool arrived, bool left, int vendo
// Avoid race conditions
m_usbEvents.waitForFinished();
}
if (!m_usbEvents.isRunning()) {
m_completed = false;
m_usbEvents = QtConcurrent::run(handleUsbEvents, static_cast<libusb_context*>(m_ctx), &m_completed);
if (handle > 0) {
m_callbackHandles.insert(handle);
if (!m_usbEvents.isRunning()) {
m_completed = false;
m_usbEvents = QtConcurrent::run(handleUsbEvents, static_cast<libusb_context*>(m_ctx), &m_completed);
}
}
m_callbackHandles.insert(handle);
return handle;
}

Expand Down

0 comments on commit a1ddb45

Please sign in to comment.