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..bfa4fe7 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -3364,6 +3364,47 @@ static void test_get_childNodes(void) free_bstrs(); } +static void test_null_owner(void) +{ + IXMLDOMNodeList *node_list; + VARIANT_BOOL b; + IXMLDOMDocument *doc; + IXMLDOMNode *node; + IXMLDOMElement *element; + HRESULT hr; + LONG i, len; + + doc = create_document(&IID_IXMLDOMDocument); + + hr = IXMLDOMDocument_loadXML( doc, _bstr_(complete4A), &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); + + hr = IXMLDOMElement_get_childNodes( element, &node_list ); + EXPECT_HR(hr, S_OK); + + hr = IXMLDOMNodeList_get_length( node_list, &len ); + EXPECT_HR(hr, S_OK); + ok( len == 4, "len %d\n", len); + + for(i = 0; i < len; i++) { + hr = IXMLDOMNodeList_get_item(node_list, 0, &node); + EXPECT_HR(hr, S_OK); + + hr = IXMLDOMElement_get_ownerDocument( element, NULL ); + EXPECT_HR(hr, E_INVALIDARG); + + IXMLDOMNode_Release(node); + } + IXMLDOMNodeList_Release( node_list ); + IXMLDOMElement_Release(element); + IXMLDOMDocument_Release( doc ); + free_bstrs(); +} + static void test_get_firstChild(void) { static const WCHAR xmlW[] = {'x','m','l',0}; @@ -11964,6 +12005,8 @@ START_TEST(domdoc) test_xsltemplate(); test_xsltext(); + test_null_owner(); + if (is_clsid_supported(&CLSID_MXNamespaceManager40, &IID_IMXNamespaceManager)) { test_mxnamespacemanager();