Skip to content

Commit dd16e7c

Browse files
JosepMaJAZYouw
authored andcommitted
Fix uninitialized strings on Windows (libusb#109)
Fix for unusual cases where the hardware does not return the name and the string is not initialized at all.
1 parent 7d93b43 commit dd16e7c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

windows/hid.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,20 +437,23 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
437437
cur_dev->path = NULL;
438438

439439
/* Serial Number */
440+
wstr[0]= 0x0000;
440441
res = HidD_GetSerialNumberString(write_handle, wstr, sizeof(wstr));
441442
wstr[WSTR_LEN-1] = 0x0000;
442443
if (res) {
443444
cur_dev->serial_number = _wcsdup(wstr);
444445
}
445446

446447
/* Manufacturer String */
448+
wstr[0]= 0x0000;
447449
res = HidD_GetManufacturerString(write_handle, wstr, sizeof(wstr));
448450
wstr[WSTR_LEN-1] = 0x0000;
449451
if (res) {
450452
cur_dev->manufacturer_string = _wcsdup(wstr);
451453
}
452454

453455
/* Product String */
456+
wstr[0]= 0x0000;
454457
res = HidD_GetProductString(write_handle, wstr, sizeof(wstr));
455458
wstr[WSTR_LEN-1] = 0x0000;
456459
if (res) {

0 commit comments

Comments
 (0)