[PATCH 0/1] MR8421: dxgi/tests: Fix out-of-bound in test_cursor_clipping.
Missing a bound check for "modes". -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8421
From: Yuxuan Shui <yshui(a)codeweavers.com> Missing a bound check for "modes". --- dlls/dxgi/tests/dxgi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index cb8bec5c666..47905bed66d 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -6912,8 +6912,10 @@ static void test_cursor_clipping(IUnknown *device, BOOL is_d3d12) if (modes[mode_idx].Width != width && modes[mode_idx].Height != height) break; } - ok(modes[mode_idx].Width != width && modes[mode_idx].Height != height, + ok(mode_idx < mode_count && modes[mode_idx].Width != width && modes[mode_idx].Height != height, "Failed to find a different mode than %ux%u.\n", width, height); + if (mode_idx >= mode_count) + continue; ret = ClipCursor(NULL); ok(ret, "ClipCursor failed, error %#lx.\n", GetLastError()); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8421
I believe the intent of that check *was*, simply, "mode_idx < mode_count". We can just change the ok() to that. We don't need an "if (...)" continue afterward, either. A test failure is a test failure. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8421#note_107865
On Wed Jun 25 13:15:16 2025 +0000, Elizabeth Figura wrote:
I believe the intent of that check *was*, simply, "mode_idx < mode_count". We can just change the ok() to that. We don't need an "if (...)" continue afterward, either. A test failure is a test failure. the `if()` is needed because there are uses of `modes[mode_idx]` later, which would be out of bound.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/8421#note_107899
participants (3)
-
Elizabeth Figura (@zfigura) -
Yuxuan Shui -
Yuxuan Shui (@yshui)