From 7277199d6e671595c776c74f8704e3ab083899bb Mon Sep 17 00:00:00 2001 From: jb Date: Sun, 10 Dec 2023 13:24:31 +0100 Subject: [PATCH] windisplay: fix handling of invalid devices, replaced 0 with nullptr Fixes #1559 Closes #1563 --- panda/src/windisplay/winGraphicsWindow.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 7878484a79..eea2a3a7e4 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -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.