diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 1ddc9bf..90b5bde 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -654,6 +654,8 @@ HRESULT node_has_childnodes(const xmlnode *This, VARIANT_BOOL *ret) HRESULT node_get_owner_doc(const xmlnode *This, IXMLDOMDocument **doc) { + if(!doc) + return E_INVALIDARG; return get_domdoc_from_xmldoc(This->node->doc, (IXMLDOMDocument3**)doc); } diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index f7f57ac..6ec199c 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -3364,6 +3364,61 @@ static void test_get_childNodes(void) free_bstrs(); } +static void test_null_owner_recursive(IXMLDOMElement *root_element) +{ + IXMLDOMNodeList *node_list; + IXMLDOMNode *node; + IXMLDOMElement *element; + HRESULT hr; + LONG i, len; + + hr = IXMLDOMElement_get_childNodes( root_element, &node_list ); + EXPECT_HR(hr, S_OK); + + hr = IXMLDOMNodeList_get_length( node_list, &len ); + EXPECT_HR(hr, S_OK); + + for(i = 0; i < len; i++) { + hr = IXMLDOMNodeList_get_item(node_list, 0, &node); + EXPECT_HR(hr, S_OK); + + hr = IXMLDOMNode_get_ownerDocument( node, NULL ); + EXPECT_HR(hr, E_INVALIDARG); + + hr = IXMLDOMNode_QueryInterface( node, &IID_IXMLDOMElement, (void**)&element ); + if(hr == S_OK) { + test_null_owner_recursive(element); + IXMLDOMElement_Release(element); + } + + IXMLDOMNode_Release(node); + } + IXMLDOMNodeList_Release( node_list ); +} + +static void test_null_owner(void) +{ + VARIANT_BOOL b; + IXMLDOMDocument *doc; + IXMLDOMElement *element; + HRESULT hr; + + doc = create_document(&IID_IXMLDOMDocument); + + hr = IXMLDOMDocument_loadXML( doc, _bstr_(szNodeTypesXML), &b ); + EXPECT_HR(hr, S_OK); + ok( b == VARIANT_TRUE, "failed to load XML string\n"); + + hr = IXMLDOMDocument_get_documentElement( doc, &element ); + EXPECT_HR(hr, S_OK); + + test_null_owner_recursive(element); + + IXMLDOMElement_Release(element); + IXMLDOMDocument_Release( doc ); + free_bstrs(); +} + static void test_get_firstChild(void) { static const WCHAR xmlW[] = {'x','m','l',0}; @@ -11964,6 +12019,8 @@ START_TEST(domdoc) test_xsltemplate(); test_xsltext(); + test_null_owner(); + if (is_clsid_supported(&CLSID_MXNamespaceManager40, &IID_IMXNamespaceManager)) { test_mxnamespacemanager();