From: Alex Henrie Subject: [PATCH] comctl32: Return TRUE from LVM_REDRAWITEMS with bad indices. Message-Id: <20170220070612.16103-1-alexhenrie24@gmail.com> Date: Mon, 20 Feb 2017 00:06:12 -0700 Fixes https://bugs.winehq.org/show_bug.cgi?id=42490 Signed-off-by: Alex Henrie --- dlls/comctl32/listview.c | 8 ++------ dlls/comctl32/tests/listview.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 56e2563c17..c01d816c46 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -7989,12 +7989,8 @@ static BOOL LISTVIEW_IsItemVisible(const LISTVIEW_INFO *infoPtr, INT nItem) static BOOL LISTVIEW_RedrawItems(const LISTVIEW_INFO *infoPtr, INT nFirst, INT nLast) { INT i; - - if (nLast < nFirst || min(nFirst, nLast) < 0 || - max(nFirst, nLast) >= infoPtr->nItemCount) - return FALSE; - - for (i = nFirst; i <= nLast; i++) + + for (i = max(nFirst, 0); i <= min(nLast, infoPtr->nItemCount - 1); i++) LISTVIEW_InvalidateItem(infoPtr, i); return TRUE; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 6d21b05436..f49767309c 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -5529,6 +5529,43 @@ static void test_LVM_SETITEMTEXT(void) DestroyWindow(hwnd); } +static void test_LVM_REDRAWITEMS(void) +{ + HWND list; + DWORD ret; + + list = create_listview_control(LVS_ICON); + ok(list != NULL, "failed to create listview window\n"); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 0); + expect(TRUE, ret); + + insert_item(list, 0); + + ret = SendMessageA(list, LVM_REDRAWITEMS, -1, 0); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, -1); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 0); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 1); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 2); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 1, 0); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 2, 3); + expect(TRUE, ret); + + DestroyWindow(list); +} + static void test_imagelists(void) { HWND hwnd, header; @@ -5903,6 +5940,7 @@ START_TEST(listview) test_createdragimage(); test_dispinfo(); test_LVM_SETITEMTEXT(); + test_LVM_REDRAWITEMS(); test_imagelists(); test_deleteitem(); test_insertitem(); -- 2.11.1