This fixes a problem in my previous listview patch reported by Rein Klazes. Changelog: Paul Rupe <prupe@myrealbox.com> Remove freed sublist on failure in LISTVIEW_InsertItemT -- Paul Rupe "She smiled, in the end." p r u p e @ m y r e a l b o x . c o m | Oppose government police-ware on your PC! | Stop the Consumer Broadband and Digital Television Promotion Act! | <http://www.eff.org/alerts/20020322_eff_cbdtpa_alert.html>
Index: dlls/comctl32/listview.c =================================================================== RCS file: /home/wine/wine/dlls/comctl32/listview.c,v retrieving revision 1.152 diff -u -r1.152 listview.c --- dlls/comctl32/listview.c 25 Sep 2002 03:20:01 -0000 1.152 +++ dlls/comctl32/listview.c 26 Sep 2002 16:46:39 -0000 @@ -6569,7 +6569,7 @@ LONG lStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); UINT uView = lStyle & LVS_TYPEMASK; INT nItem = -1; - HDPA hdpaSubItems; + HDPA hdpaSubItems = NULL; NMLISTVIEW nmlv; LISTVIEW_ITEM *lpItem; BOOL is_sorted; @@ -6599,6 +6599,11 @@ is_sorted = (lStyle & (LVS_SORTASCENDING | LVS_SORTDESCENDING)) && !(lStyle & LVS_OWNERDRAWFIXED) && (LPSTR_TEXTCALLBACKW != lpLVItem->pszText); + nItem = DPA_InsertPtr( infoPtr->hdpaItems, + is_sorted ? GETITEMCOUNT( infoPtr ) + 1 : lpLVItem->iItem, + hdpaSubItems ); + if (nItem == -1) goto fail; + if (!LISTVIEW_SetItemT(infoPtr, lpLVItem, isW)) goto fail; /* if we're sorted, sort the list, and update the index */ @@ -6609,14 +6614,6 @@ if (nItem == -1) goto fail; } - /* Add the subitem list to the items array. Do this last in case we go to - * fail during the above. - */ - nItem = DPA_InsertPtr( infoPtr->hdpaItems, - is_sorted ? GETITEMCOUNT( infoPtr ) + 1 : lpLVItem->iItem, - hdpaSubItems ); - if (nItem == -1) goto fail; - LISTVIEW_ShiftIndices(infoPtr, nItem, 1); lpItem->valid = TRUE; @@ -6642,7 +6639,14 @@ return nItem; fail: - DPA_Destroy (hdpaSubItems); + if (hdpaSubItems) + { + /* Remove soon-to-be-destroyed subitem from the array if we failed */ + nItem = DPA_GetPtrIndex(infoPtr->hdpaItems, hdpaSubItems); + if (nItem != -1) + DPA_SetPtr(infoPtr->hdpaItems, nItem, NULL); + DPA_Destroy (hdpaSubItems); + } COMCTL32_Free (lpItem); return -1; }