Gabriel Ivăncescu : mshtml: Hold a ref to the location on the window side.

Alexandre Julliard julliard at winehq.org
Fri Nov 5 17:15:52 CDT 2021


Module: wine
Branch: master
Commit: 0be2db2ecd0460a3a46e18562e58c5838256795d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0be2db2ecd0460a3a46e18562e58c5838256795d

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Thu Nov  4 16:10:51 2021 +0200

mshtml: Hold a ref to the location on the window side.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlwindow.c | 5 ++---
 dlls/mshtml/tests/dom.c  | 4 +---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 0b25e71063d..635b046ea39 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -68,9 +68,7 @@ static inline BOOL is_outer_window(HTMLWindow *window)
 
 static HRESULT get_location(HTMLInnerWindow *This, HTMLLocation **ret)
 {
-    if(This->location) {
-        IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
-    }else {
+    if(!This->location) {
         HRESULT hres;
 
         hres = HTMLLocation_Create(This, &This->location);
@@ -78,6 +76,7 @@ static HRESULT get_location(HTMLInnerWindow *This, HTMLLocation **ret)
             return hres;
     }
 
+    IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
     *ret = This->location;
     return S_OK;
 }
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 03f5c0431ea..ea5b2108100 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -6015,7 +6015,6 @@ static void test_location(IHTMLDocument2 *doc)
     IHTMLLocation *location, *location2;
     IHTMLWindow2 *window;
     BSTR str;
-    ULONG ref;
     HRESULT hres;
 
     hres = IHTMLDocument2_get_location(doc, &location);
@@ -6051,8 +6050,7 @@ static void test_location(IHTMLDocument2 *doc)
     ok(!lstrcmpW(str, L"about:blank"), "unexpected href %s\n", wine_dbgstr_w(str));
     SysFreeString(str);
 
-    ref = IHTMLLocation_Release(location);
-    ok(!ref, "location should be destroyed here\n");
+    IHTMLLocation_Release(location);
 }
 
 static void test_plugins_col(IHTMLDocument2 *doc)




More information about the wine-cvs mailing list