Nikolay Sivov : msxml3: Check for Null out pointer in node creation ( with tests).

Alexandre Julliard julliard at winehq.org
Fri Feb 12 10:17:42 CST 2010


Module: wine
Branch: master
Commit: e2b727807d8a8d8cbc8ccb5fc001f5bdece7827e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e2b727807d8a8d8cbc8ccb5fc001f5bdece7827e

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Fri Feb 12 00:06:51 2010 +0300

msxml3: Check for Null out pointer in node creation (with tests).

---

 dlls/msxml3/domdoc.c       |    4 ++++
 dlls/msxml3/tests/domdoc.c |    8 ++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index 77d1d2e..d4be6b6 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -1046,6 +1046,8 @@ static HRESULT WINAPI domdoc_createElement(
 
     TRACE("%p->(%s,%p)\n", iface, debugstr_w(tagname), element);
 
+    if (!element) return E_INVALIDARG;
+
     xml_name = xmlChar_from_wchar(tagname);
     xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL);
     xmldoc_add_orphan(xmlnode->doc, xmlnode);
@@ -1346,6 +1348,8 @@ static HRESULT WINAPI domdoc_createNode(
 
     TRACE("(%p)->(type,%s,%s,%p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node);
 
+    if(!node) return E_INVALIDARG;
+
     if(namespaceURI && namespaceURI[0])
         FIXME("nodes with namespaces currently not supported.\n");
 
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 1b134af..3ef37fc 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -1664,6 +1664,11 @@ static void test_create(void)
     ok( r == S_OK, "returns %08x\n", r );
     if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
 
+    V_VT(&var) = VT_I1;
+    V_I1(&var) = NODE_ELEMENT;
+    r = IXMLDOMDocument_createNode( doc, var, str, NULL, NULL );
+    ok( r == E_INVALIDARG, "returns %08x\n", r );
+
     V_VT(&var) = VT_R4;
     V_R4(&var) = NODE_ELEMENT;
     r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
@@ -3641,6 +3646,9 @@ static void test_nodeTypeTests( void )
     if( hr != S_OK )
         return;
 
+    hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), NULL);
+    ok(hr == E_INVALIDARG, "ret %08x\n", hr );
+
     hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
     ok(hr == S_OK, "ret %08x\n", hr );
     if(hr == S_OK)




More information about the wine-cvs mailing list