Skip to content
Permalink
Browse files

hid_error() could return a null, which causes the program to crash with

std::logic_error()
  • Loading branch information...
TheQuantumPhysicist committed Aug 9, 2019
1 parent 8adde33 commit 6ca033d2784cbdf886b54d4acc4b8f6e1417cd22
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/device/device_io_hid.cpp
@@ -44,7 +44,8 @@ namespace hw {

static std::string safe_hid_error(hid_device *hwdev) {
if (hwdev) {
return std::string((char*)hid_error(hwdev));
const char* error_str = (const char*)hid_error(hwdev);
return std::string(error_str == nullptr ? "Unknown error" : error_str);
}
return std::string("NULL device");
}

0 comments on commit 6ca033d

Please sign in to comment.
You can’t perform that action at this time.