From 7900e52291ec1293add1e3df949e12e7080f36e9 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 15 Jun 2022 17:40:24 +1000 Subject: [PATCH] Adding status check for `GetSerial()` for the EVGA Keyboard to resolve #2531 * Adding status check for `hid_get_serial_number_string()` to ensure serial string is valid. --- Controllers/EVGAUSBController/EVGAKeyboardController.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Controllers/EVGAUSBController/EVGAKeyboardController.cpp b/Controllers/EVGAUSBController/EVGAKeyboardController.cpp index 55b7f48a..eb3eea96 100644 --- a/Controllers/EVGAUSBController/EVGAKeyboardController.cpp +++ b/Controllers/EVGAUSBController/EVGAKeyboardController.cpp @@ -89,7 +89,13 @@ std::string EVGAKeyboardController::GetSerial() const uint8_t sz = HID_MAX_STR; wchar_t tmp[sz]; - hid_get_serial_number_string(dev, tmp, sz); + int ret = hid_get_serial_number_string(dev, tmp, sz); + + if (ret != 0) + { + return(""); + } + std::wstring w_tmp = std::wstring(tmp); std::string serial = std::string(w_tmp.begin(), w_tmp.end());