[PATCH v2 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.") -- v2: dinput: Use the correct array index in keyboard_create_device(). 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..7d063308d69 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -211,7 +211,7 @@ HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirect if (FAILED(hr = dinput_device_init_device_format( &impl->base.IDirectInputDevice8W_iface ))) goto failed; - 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
If there's a regression it's more likely related to the addition of DIPROP_SCANCODE support.
I reverted all of the `DIPROP_SCANCODE` switch case changes and the segfault still happens (so the loop is definitely introducing/exposing the problem) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78367
After some testing I discovered the segfault is caused by the 0001 patch of dinput-scancode staging patchset (and the 0002 patchset introduces some test failures) Enabling scancode auto-detection solves both of these issues though I have a different version of this patch that doesn't regress mainline Wine (but it still causes test failures/tests succeeding inside of a todo block on staging) :frog: -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78372
So there is no upstream regression then? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78384
On Mon Aug 12 06:13:44 2024 +0000, Rémi Bernon wrote:
So there is no upstream regression then? I guess upstream is okay-ish (but there might still be potential OOB array access for object_properties)
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249#note_78387
This merge request was closed by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6249
participants (2)
-
Aida Jonikienė -
Rémi Bernon