Fixed crash if vendor or product strings are empty

This commit is contained in:
Sam Lantinga 2021-06-10 16:28:32 -07:00
parent 25fc40b0bd
commit 0e62926ec5

View File

@ -733,9 +733,13 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
if (dev_vid && dev_pid) { if (dev_vid && dev_pid) {
string_cache = usb_string_cache_find(&desc, handle); string_cache = usb_string_cache_find(&desc, handle);
if (string_cache) { if (string_cache) {
if (string_cache->vendor) {
cur_dev->manufacturer_string = wcsdup(string_cache->vendor); cur_dev->manufacturer_string = wcsdup(string_cache->vendor);
}
if (string_cache->product) {
cur_dev->product_string = wcsdup(string_cache->product); cur_dev->product_string = wcsdup(string_cache->product);
} }
}
} else { } else {
if (desc.iManufacturer > 0) if (desc.iManufacturer > 0)
cur_dev->manufacturer_string = cur_dev->manufacturer_string =