From: Thomas Csovcsity <thc.fr13nd(a)gmail.com> In TREEVIEW_Collapse the TREEVIEW_SendExpanding call could change the item->firstChild value, therefore check it before for early return. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=23077 --- dlls/comctl32/treeview.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index 0618eeacf84..9bb5559d7dd 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -3407,12 +3407,17 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, if (!TREEVIEW_HasChildren(infoPtr, item)) return FALSE; - if (bUser && TREEVIEW_SendExpanding(infoPtr, item, action)) - return TRUE; - + /* + * the child items may not actually exist, they could be virtual. + * Just use item->firstChild to check for physical children, + * before TREEVIEW_SendExpanding may change it. + */ if (item->firstChild == NULL) return FALSE; + if (bUser && TREEVIEW_SendExpanding(infoPtr, item, action)) + return TRUE; + wasExpanded = (item->state & TVIS_EXPANDED) != 0; item->state &= ~TVIS_EXPANDED; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9442