internal/gamepad: bug fix: possible crash at iterating gamepads

Closes #2603
This commit is contained in:
Hajime Hoshi 2023-03-17 11:40:21 +09:00
parent c77673d96d
commit 22dfdfc418

View File

@ -429,7 +429,8 @@ func supportsXInput(guid windows.GUID) (bool, error) {
} }
size := uint32(unsafe.Sizeof(rdi)) size := uint32(unsafe.Sizeof(rdi))
if _, err := _GetRawInputDeviceInfoW(ridl[i].hDevice, _RIDI_DEVICEINFO, unsafe.Pointer(&rdi), &size); err != nil { if _, err := _GetRawInputDeviceInfoW(ridl[i].hDevice, _RIDI_DEVICEINFO, unsafe.Pointer(&rdi), &size); err != nil {
return false, err // GetRawInputDeviceInfoW can return an error (#2603).
continue
} }
if uint32(rdi.hid.dwVendorId)|(uint32(rdi.hid.dwProductId)<<16) != guid.Data1 { if uint32(rdi.hid.dwVendorId)|(uint32(rdi.hid.dwProductId)<<16) != guid.Data1 {