From: Jacek Caban Subject: [PATCH 2/2] mshtml: Fix NULL offset parent handling in IHTMLElement::get_offsetParent. Message-Id: <1f0d07a4-9d4d-3083-4a78-2b839fe085bb@codeweavers.com> Date: Mon, 29 Mar 2021 13:21:43 +0200 From: Dmitry Kislyuk Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50875 Signed-off-by: Dmitry Kislyuk Signed-off-by: Jacek Caban --- dlls/mshtml/htmlelem.c | 2 +- dlls/mshtml/tests/dom.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 9e5d184ff3fd..81993db224d0 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1628,7 +1628,7 @@ static HRESULT WINAPI HTMLElement_get_offsetParent(IHTMLElement *iface, IHTMLEle if(!nsparent) { *p = NULL; - hres = S_OK; + return S_OK; } hres = get_element(nsparent, &parent); diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index a6ca66a28858..1253e9cdea8a 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -1299,11 +1299,14 @@ static void _test_elem_offset(unsigned line, IUnknown *unk, const WCHAR *parent_ hres = IHTMLElement_get_offsetParent(elem, &off_parent); ok_(__FILE__,line) (hres == S_OK, "get_offsetParent failed: %08x\n", hres); - - _test_elem_tag(line, (IUnknown*)off_parent, parent_tag); - IHTMLElement_Release(off_parent); - IHTMLElement_Release(elem); + + if(off_parent) { + _test_elem_tag(line, (IUnknown*)off_parent, parent_tag); + IHTMLElement_Release(off_parent); + }else { + ok_(__FILE__,line) (parent_tag == NULL, "Offset parent is NULL. %s expected\n", wine_dbgstr_w(parent_tag)); + } } #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b) @@ -8937,6 +8940,10 @@ static void test_elems(IHTMLDocument2 *doc) IHTMLElement_Release(elem); } + elem = doc_get_body(doc); + test_elem_offset((IUnknown*)elem, NULL); + IHTMLElement_Release(elem); + elem = get_elem_by_id(doc, L"sc", TRUE); if(elem) { IHTMLScriptElement *script;