From: Tobiasz Laskowski <tlaskowski@codeweavers.com> --- dlls/user32/listbox.c | 2 +- dlls/user32/tests/listbox.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index c569b296842..55514c3b0b2 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -395,8 +395,8 @@ static LRESULT LISTBOX_SetTopItem( LB_DESCR *descr, INT index, BOOL scroll ) TRACE("setting top item %d, scroll %d\n", index, scroll); + if (index < 0 || index >= descr->nb_items) return LB_ERR; if (index > max) index = max; - if (index < 0) index = 0; if (descr->style & LBS_MULTICOLUMN) index -= index % descr->page_size; if (descr->top_item == index) return LB_OKAY; if (scroll) diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c index b2036b04525..697d66b2263 100644 --- a/dlls/user32/tests/listbox.c +++ b/dlls/user32/tests/listbox.c @@ -2620,28 +2620,22 @@ static void test_LB_SETTOPINDEX(void) { /* Greater than or equal to item count (out of bounds) */ ret = SendMessageA(listbox, LB_SETTOPINDEX, 10, 0); - todo_wine ok(ret == LB_ERR, "got %d\n", ret); ret = SendMessageA(listbox, LB_GETTOPINDEX, 0, 0); - todo_wine ok(ret == 2, "got %d\n", ret); ret = SendMessageA(listbox, LB_SETTOPINDEX, 20, 0); - todo_wine ok(ret == LB_ERR, "Expected LB_ERR, got %d\n", ret); ret = SendMessageA(listbox, LB_GETTOPINDEX, 0, 0); - todo_wine ok(ret == 2, "got %d\n", ret); /* Negative (out of bounds) */ ret = SendMessageA(listbox, LB_SETTOPINDEX, -1, 0); - todo_wine ok(ret == LB_ERR, "Expected LB_ERR, got %d\n", ret); ret = SendMessageA(listbox, LB_GETTOPINDEX, 0, 0); - todo_wine ok(ret == 2, "got %d\n", ret); DestroyWindow(listbox); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11507