windisplay: fix handling of invalid devices, replaced 0 with nullptr

Fixes #1559
Closes #1563
This commit is contained in:
jb 2023-12-10 13:24:31 +01:00 committed by rdb
parent 1c4a91858b
commit 7277199d6e

View File

@ -660,18 +660,18 @@ initialize_input_devices() {
_input = device;
// Get the number of devices.
if (GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
if ((int)GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
return;
}
// Allocate the array to hold the DeviceList
pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
if (pRawInputDeviceList==0) {
if (pRawInputDeviceList == nullptr) {
return;
}
// Fill the Array
if (GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
if ((int)GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
return;
}
@ -680,13 +680,13 @@ initialize_input_devices() {
if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
// Fetch information about specified mouse device.
UINT nSize;
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0) {
return;
if ((int)GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)nullptr, &nSize) != 0) {
continue;
}
char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
if (psName == 0) return;
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
return;
if (psName == nullptr) continue;
if ((int)GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
continue;
}
// If it's not an RDP mouse, add it to the list of raw mice.