Browse Source

device: don't crash on Linux if no devices are found

Fixes #634
Closes #635
Rishabh Tewari 6 years ago
parent
commit
bfb50ab7ff
1 changed files with 3 additions and 0 deletions
  1. 3 0
      panda/src/device/linuxInputDeviceManager.cxx

+ 3 - 0
panda/src/device/linuxInputDeviceManager.cxx

@@ -61,6 +61,9 @@ LinuxInputDeviceManager() {
 
 
     // We'll want to sort the devices by index, since the order may be
     // We'll want to sort the devices by index, since the order may be
     // meaningful (eg. for the Xbox wireless receiver).
     // meaningful (eg. for the Xbox wireless receiver).
+    if (indices.empty()) {
+      return;
+    }
     std::sort(indices.begin(), indices.end());
     std::sort(indices.begin(), indices.end());
     _evdev_devices.resize(indices.back() + 1, nullptr);
     _evdev_devices.resize(indices.back() + 1, nullptr);