Sfoglia il codice sorgente

Check for empty context was added

Denis V. Dedkov 1 anno fa
parent
commit
d2471371dc
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      src/libusbdevice.cpp

+ 5 - 0
src/libusbdevice.cpp

@@ -25,6 +25,11 @@ LibUsbDevice::~LibUsbDevice()
 
 void LibUsbDevice::openDevice(uint16_t vendorId, uint16_t productId)
 {
+    if (!m_context) {
+        std::cerr << "Context not initialized! Unable to open device";
+        return;
+    }
+
     m_device = libusb_open_device_with_vid_pid(m_context, vendorId, productId);
 }