Nikolay Sivov : comctl32/listview: Filter invalid indices when setting selection mark.

Alexandre Julliard julliard at winehq.org
Mon Aug 1 16:48:57 CDT 2016


Module: wine
Branch: master
Commit: 5faab43d34f48030fdbf6689c92aa3e82e00aefc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5faab43d34f48030fdbf6689c92aa3e82e00aefc

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Aug  1 12:18:50 2016 +0300

comctl32/listview: Filter invalid indices when setting selection mark.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/listview.c       |  3 ++-
 dlls/comctl32/tests/listview.c | 24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index cfdb7de..a32c594 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -9053,7 +9053,8 @@ static INT LISTVIEW_SetSelectionMark(LISTVIEW_INFO *infoPtr, INT nIndex)
 
   TRACE("(nIndex=%d)\n", nIndex);
 
-  infoPtr->nSelectionMark = nIndex;
+  if (nIndex >= -1 && nIndex < infoPtr->nItemCount)
+    infoPtr->nSelectionMark = nIndex;
 
   return nOldIndex;
 }
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 549dc21..8214d7b 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2257,7 +2257,29 @@ static void test_multiselect(void)
     item_count = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
     expect(items, item_count);
 
-    for (i = 0; i < 4; i++) {
+    r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
+    ok(r == -1, "got %d\n", r);
+
+    r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, 0);
+    ok(r == -1, "got %d\n", r);
+
+    r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, 0);
+    ok(r == 0, "got %d\n", r);
+
+    /* out of range index */
+    r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, items);
+    ok(r == 0, "got %d\n", r);
+
+    r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
+    ok(r == 0, "got %d\n", r);
+
+    r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -2);
+    ok(r == 0, "got %d\n", r);
+
+    r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
+    ok(r == 0, "got %d\n", r);
+
+    for (i = 0; i < sizeof(task_list)/sizeof(task_list[0]); i++) {
         DWORD selected_count;
         LVITEMA item;
 




More information about the wine-cvs mailing list