diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index cd561b5fb42..6c948d32011 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -848,6 +848,11 @@ static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLEl if(FAILED(hres)) return hres; + if(!node) { + *p = NULL; + return S_OK; + } + hres = IHTMLDOMNode_QueryInterface(node, &IID_IHTMLElement, (void**)p); IHTMLDOMNode_Release(node); if(FAILED(hres)) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index b9f79351f4f..b892ac09736 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -5267,6 +5267,8 @@ static void test_insert_adjacent_elems(IHTMLDocument2 *doc, IHTMLElement *parent static const elem_type_t br_div_br[] = {ET_BR, ET_DIV, ET_BR}; elem = test_create_elem(doc, "BR"); + elem2 = test_elem_get_parent((IUnknown*)elem); + ok(!elem2, "get_parentElement returned %p\n", elem2); insert_adjacent_elem(parent, "BeforeEnd", elem); IHTMLElement_Release(elem);