aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2020-06-13 18:57:55 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2020-06-13 18:57:55 +0200
commit712c82ee94d1ef0d96becfce9bc1a7f8d95bdac1 (patch)
treeaa8fe2302bd7d005c2788566c5ba2952cc3a54f8
parent8009c37af6198e712e458d0810fe5eae4b2f0ee6 (diff)
parenta3fd24ff87eeae3d320e3ee48f1c6e1b9ba0a783 (diff)
downloadlibnitrokey-712c82ee94d1ef0d96becfce9bc1a7f8d95bdac1.tar.gz
libnitrokey-712c82ee94d1ef0d96becfce9bc1a7f8d95bdac1.tar.bz2
Merge branch 'enumerate'
Check for null pointer in the provided data Fixes #168
-rw-r--r--device.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/device.cc b/device.cc
index 9cf4dc3..20bb0c6 100644
--- a/device.cc
+++ b/device.cc
@@ -233,7 +233,10 @@ namespace {
auto pInfo = hid_enumerate(vendor_id, 0);
auto pInfo_ = pInfo;
while (pInfo != nullptr){
- auto deviceModel = product_id_to_model(vendor_id, pInfo->product_id);
+ if (pInfo->path == nullptr || pInfo->serial_number == nullptr) {
+ continue;
+ }
+ auto deviceModel = product_id_to_model(vendor_id, pInfo->product_id);
if (deviceModel.has_value()) {
std::string path(pInfo->path);
std::wstring serialNumberW(pInfo->serial_number);