diff --git a/dlls/mshtml/selection.c b/dlls/mshtml/selection.c index dfbb386b938..da8fbfa2e23 100644 --- a/dlls/mshtml/selection.c +++ b/dlls/mshtml/selection.c @@ -364,9 +364,10 @@ HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselect void detach_selection(HTMLDocumentNode *This) { - HTMLSelectionObject *iter; + HTMLSelectionObject *iter, *next; - LIST_FOR_EACH_ENTRY(iter, &This->selection_list, HTMLSelectionObject, entry) { + LIST_FOR_EACH_ENTRY_SAFE(iter, next, &This->selection_list, HTMLSelectionObject, entry) { iter->doc = NULL; + list_remove(&iter->entry); } } diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c index bfabbf40e74..b377fad4b6b 100644 --- a/dlls/mshtml/txtrange.c +++ b/dlls/mshtml/txtrange.c @@ -1760,9 +1760,10 @@ HRESULT HTMLTxtRange_Create(HTMLDocumentNode *doc, nsIDOMRange *nsrange, IHTMLTx void detach_ranges(HTMLDocumentNode *This) { - HTMLTxtRange *iter; + HTMLTxtRange *iter, *next; - LIST_FOR_EACH_ENTRY(iter, &This->range_list, HTMLTxtRange, entry) { + LIST_FOR_EACH_ENTRY_SAFE(iter, next, &This->range_list, HTMLTxtRange, entry) { iter->doc = NULL; + list_remove(&iter->entry); } }