[PATCH 0/1] MR6249: dinput: Use the correct array index in keyboard_create_device().
This fixes a segfault when launching NFS Underground. Fixes: f434ea12b83 ("dinput: Implement DIPROP_SCANCODE.") -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249
From: Aida Jonikienė <aidas957(a)gmail.com> This fixes a segfault when launching NFS Underground. Fixes: f434ea12b83 ("dinput: Implement DIPROP_SCANCODE.") --- dlls/dinput/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 8ec9dd47150..1ec061fa305 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -283,7 +283,7 @@ static HRESULT keyboard_enum_objects( IDirectInputDevice8W *iface, const DIPROPH DWORD index, i, dik; BOOL ret; - for (i = 0, index = 0; i < 512; ++i) + for (i = 0, index = 0; i < impl->base.device_format.dwNumObjs; ++i) { if (!GetKeyNameTextW( i << 16, instance.tszName, ARRAY_SIZE(instance.tszName) )) continue; if (!(dik = map_dik_code( i, 0, subtype, impl->base.dinput->dwVersion ))) continue; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6249
There are some very related test failures (maybe the updated index isn't so correct then?) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78361
On Sat Aug 10 21:00:17 2024 +0000, Aida Jonikienė wrote:
There are some very related test failures (maybe the updated index isn't so correct then?) You're changing the index in keyboard_enum_objects, which doesn't match what the commit title says. Then, `keyboard_enum_objects` is called to initialize dwNumObjs, so using that member in it will simply make it not enumerate anything.
Last, both `keyboard_enum_objects` loop (which hasn't been changed, so is unlikely causing a regression), and the new `keyboard_create_device` both use the exact same conditions, and I believe they are enumerating the exact same number of objects. If they weren't, the tests would also likely be crashing already. If there's a regression it's more likely related to the addition of DIPROP_SCANCODE support. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78363
On Sun Aug 11 07:36:24 2024 +0000, Rémi Bernon wrote:
You're changing the index in keyboard_enum_objects, which doesn't match what the commit title says. Then, `keyboard_enum_objects` is called to initialize dwNumObjs, so using that member in it will simply make it not enumerate anything. Last, both `keyboard_enum_objects` loop (which hasn't been changed, so is unlikely causing a regression), and the new `keyboard_create_device` both use the exact same conditions, and I believe they are enumerating the exact same number of objects. If they weren't, the tests would also likely be crashing already. If there's a regression it's more likely related to the addition of DIPROP_SCANCODE support. I accidentally committed the wrong change (because the loops look so similar) 🤦♀️
The tests do pass with the change in the correct place though (at least with wine-staging) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78364
participants (2)
-
Aida Jonikienė -
Rémi Bernon