From f31cd30841f36c733e48c9167b64b632aa65a0d4 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 8 Jan 2008 11:07:12 +1100 Subject: [PATCH] msxml3: createProcessingInstruction: Check arguments are valid. --- dlls/msxml3/domdoc.c | 6 ++++++ dlls/msxml3/tests/domdoc.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index d955926bb2..60a65d0d82 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -958,6 +958,12 @@ static HRESULT WINAPI domdoc_createProcessingInstruction( TRACE("%p->(%s %s %p)\n", iface, debugstr_w(target), debugstr_w(data), pi); + if(!pi) + return E_INVALIDARG; + + if(!target || lstrlenW(target) == 0) + return E_FAIL; + xml_target = xmlChar_from_wchar((WCHAR*)target); xml_content = xmlChar_from_wchar((WCHAR*)data); diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 272dfb6f35..910c044fa2 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -348,6 +348,7 @@ static void test_domdoc( void ) IXMLDOMComment *node_comment = NULL; IXMLDOMAttribute *node_attr = NULL; IXMLDOMNode *nodeChild = NULL; + IXMLDOMProcessingInstruction *nodePI = NULL; VARIANT_BOOL b; VARIANT var; BSTR str; @@ -548,6 +549,31 @@ static void test_domdoc( void ) ok( r == S_OK, "returns %08x\n", r ); IXMLDOMText_Release( node_attr); + /* test Processing Instruction */ + str = SysAllocStringLen(NULL, 0); + r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, NULL); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + r = IXMLDOMDocument_createProcessingInstruction(doc, NULL, str, &nodePI); + ok( r == E_FAIL, "returns %08x\n", r ); + r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, &nodePI); + ok( r == E_FAIL, "returns %08x\n", r ); + SysFreeString(str); + + r = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI); + ok( r == S_OK, "returns %08x\n", r ); + if(nodePI) + { + /* Last Child Checks */ + r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, NULL); + ok(r == E_INVALIDARG, "ret %08x\n", r ); + + nodeChild = (IXMLDOMNode*)0x1; + r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, &nodeChild); + ok(r == S_FALSE, "ret %08x\n", r ); + ok(nodeChild == NULL, "nodeChild not NULL\n"); + } + IXMLDOMProcessingInstruction_Release(nodePI); + r = IXMLDOMDocument_Release( doc ); ok( r == 0, "document ref count incorrect\n");