From dd16e7c16f49ad7c791a8c20a67f1d398295f995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Maria=20Antol=C3=ADn=20Segura?= Date: Mon, 28 Oct 2019 15:23:24 +0100 Subject: [PATCH] Fix uninitialized strings on Windows (#109) Fix for unusual cases where the hardware does not return the name and the string is not initialized at all. --- windows/hid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/windows/hid.c b/windows/hid.c index c31af30..d83710a 100755 --- a/windows/hid.c +++ b/windows/hid.c @@ -437,6 +437,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor cur_dev->path = NULL; /* Serial Number */ + wstr[0]= 0x0000; res = HidD_GetSerialNumberString(write_handle, wstr, sizeof(wstr)); wstr[WSTR_LEN-1] = 0x0000; if (res) { @@ -444,6 +445,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor } /* Manufacturer String */ + wstr[0]= 0x0000; res = HidD_GetManufacturerString(write_handle, wstr, sizeof(wstr)); wstr[WSTR_LEN-1] = 0x0000; if (res) { @@ -451,6 +453,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor } /* Product String */ + wstr[0]= 0x0000; res = HidD_GetProductString(write_handle, wstr, sizeof(wstr)); wstr[WSTR_LEN-1] = 0x0000; if (res) {