mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-30 16:37:39 +00:00
Fixed potential uninitialized memory access (thanks Mathieu!)
GetRawInputDeviceList() can return a different number of devices than was allocated. Fixes https://github.com/libsdl-org/SDL/issues/2759
This commit is contained in:
parent
75ea3a8d32
commit
b9784feb24
3 changed files with 6 additions and 3 deletions
|
@ -991,7 +991,8 @@ static void RAWINPUT_DetectDevices(void)
|
|||
|
||||
devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count);
|
||||
if (devices) {
|
||||
if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) != -1) {
|
||||
device_count = GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST));
|
||||
if (device_count != (UINT)-1) {
|
||||
for (i = 0; i < device_count; ++i) {
|
||||
RAWINPUT_AddDevice(devices[i].hDevice);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue