[PATCH] comctl32/listview: Do not try to invalidate for invalid item indices

Nikolay Sivov nsivov at codeweavers.com
Fri Mar 9 10:53:14 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

Invalidation in LVM_SETITEM/LVM_SETITEMSTATE handlers could end up using
item index that is no longer valid, leading to assertion. That could happen
if item state change notification handler removes items.

 dlls/comctl32/listview.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 4a2df808ad..d63c23a659 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -1727,7 +1727,9 @@ static inline void LISTVIEW_InvalidateItem(const LISTVIEW_INFO *infoPtr, INT nIt
 {
     RECT rcBox;
 
-    if(!is_redrawing(infoPtr)) return; 
+    if (!is_redrawing(infoPtr) || nItem < 0 || nItem >= infoPtr->nItemCount)
+        return;
+
     LISTVIEW_GetItemBox(infoPtr, nItem, &rcBox);
     LISTVIEW_InvalidateRect(infoPtr, &rcBox);
 }
-- 
2.16.1




More information about the wine-devel mailing list