From 776f512d110b0a633997ecc0b3cd086c4c8dbf10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Zimmerer=20Murta?= Date: Thu, 28 Jan 2021 22:08:04 -0300 Subject: [PATCH] Skips Razer device loading if invalid data is received. This probably happens due to a general issue with OpenRazer windows driver. The "fix" here, simply skips loading the driver if it identifies the device information fetched doesn't make sense -- instead of employing NULL references at run time. The proper fix for this issue seems to be completely remove this razer support and move to the new RazerController approach being developed in razer_controller branch. Related issue: #1047. --- .../OpenRazerController/OpenRazerWindowsDetect.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Controllers/OpenRazerController/OpenRazerWindowsDetect.cpp b/Controllers/OpenRazerController/OpenRazerWindowsDetect.cpp index e8c400285..a0851ce12 100644 --- a/Controllers/OpenRazerController/OpenRazerWindowsDetect.cpp +++ b/Controllers/OpenRazerController/OpenRazerWindowsDetect.cpp @@ -142,6 +142,8 @@ void DetectOpenRazerControllers(std::vector &rgb_controllers) num = init_razer_kbd_driver(&hdev); for (unsigned int i = 0; i < num; i++) { + if (hdev[i].dev.attr_count < 1) continue; + device_fn_type* device_fn = new device_fn_type; load_device_fn(device_fn, &hdev[i].dev); @@ -164,6 +166,8 @@ void DetectOpenRazerControllers(std::vector &rgb_controllers) num = init_razer_mouse_driver(&hdev); for (unsigned int i = 0; i < num; i++) { + if (hdev[i].dev.attr_count < 1) continue; + device_fn_type* device_fn = new device_fn_type; load_device_fn(device_fn, &hdev[i].dev); @@ -186,6 +190,8 @@ void DetectOpenRazerControllers(std::vector &rgb_controllers) num = init_razer_mousemat_driver(&hdev); for (unsigned int i = 0; i < num; i++) { + if (hdev[i].dev.attr_count < 1) continue; + device_fn_type* device_fn = new device_fn_type; load_device_fn(device_fn, &hdev[i].dev); @@ -208,6 +214,8 @@ void DetectOpenRazerControllers(std::vector &rgb_controllers) num = init_razer_accessory_driver(&hdev); for (unsigned int i = 0; i < num; i++) { + if (hdev[i].dev.attr_count < 1) continue; + device_fn_type* device_fn = new device_fn_type; load_device_fn(device_fn, &hdev[i].dev); @@ -230,6 +238,8 @@ void DetectOpenRazerControllers(std::vector &rgb_controllers) num = init_razer_kraken_driver(&hdev); for (unsigned int i = 0; i < num; i++) { + if (hdev[i].dev.attr_count < 1) continue; + device_fn_type* device_fn = new device_fn_type; load_device_fn(device_fn, &hdev[i].dev); @@ -252,6 +262,8 @@ void DetectOpenRazerControllers(std::vector &rgb_controllers) num = init_razer_core_driver(&hdev); for (unsigned int i = 0; i < num; i++) { + if (hdev[i].dev.attr_count < 1) continue; + device_fn_type* device_fn = new device_fn_type; load_device_fn(device_fn, &hdev[i].dev);