From 0e62926ec55e6bb20b09b6ea4695d23d0ac6e1d0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 10 Jun 2021 16:28:32 -0700 Subject: [PATCH] Fixed crash if vendor or product strings are empty --- src/hidapi/libusb/hid.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hidapi/libusb/hid.c b/src/hidapi/libusb/hid.c index dfc9ecb02..acbffab77 100644 --- a/src/hidapi/libusb/hid.c +++ b/src/hidapi/libusb/hid.c @@ -733,8 +733,12 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, if (dev_vid && dev_pid) { string_cache = usb_string_cache_find(&desc, handle); if (string_cache) { - cur_dev->manufacturer_string = wcsdup(string_cache->vendor); - cur_dev->product_string = wcsdup(string_cache->product); + if (string_cache->vendor) { + cur_dev->manufacturer_string = wcsdup(string_cache->vendor); + } + if (string_cache->product) { + cur_dev->product_string = wcsdup(string_cache->product); + } } } else { if (desc.iManufacturer > 0)