From 78259fceb3c591f91471ad8bd98d843e0d030bae Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 24 Sep 2019 19:04:55 +0200 Subject: [PATCH] msxml3: Don't return NULL namespace and local name in saxreader callbacks. Signed-off-by: Piotr Caban Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/msxml3/saxreader.c | 10 ++++++---- dlls/msxml3/tests/saxreader.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/dlls/msxml3/saxreader.c b/dlls/msxml3/saxreader.c index 04fab81708c..fc27260cc2c 100644 --- a/dlls/msxml3/saxreader.c +++ b/dlls/msxml3/saxreader.c @@ -149,6 +149,8 @@ static saxreader_feature get_saxreader_feature(const WCHAR *name) return FeatureUnknown; } +static const WCHAR empty_str; + struct bstrpool { BSTR *pool; @@ -1665,8 +1667,8 @@ static void libxmlStartElementNS( &uri, &local, &element->qname, &This->IVBSAXAttributes_iface); else hr = ISAXContentHandler_startElement(handler->handler, - uri, SysStringLen(uri), - local, SysStringLen(local), + uri ? uri : &empty_str, SysStringLen(uri), + local ? local : &empty_str, SysStringLen(local), element->qname, SysStringLen(element->qname), &This->ISAXAttributes_iface); @@ -1739,8 +1741,8 @@ static void libxmlEndElementNS( else hr = ISAXContentHandler_endElement( handler->handler, - uri, SysStringLen(uri), - local, SysStringLen(local), + uri ? uri : &empty_str, SysStringLen(uri), + local ? local : &empty_str, SysStringLen(local), element->qname, SysStringLen(element->qname)); free_attribute_values(This); diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index d1076f58ead..4e77b00a639 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -1162,6 +1162,9 @@ static HRESULT WINAPI contentHandler_startPrefixMapping( { struct call_entry call; + ok(prefix != NULL, "prefix == NULL\n"); + ok(uri != NULL, "uri == NULL\n"); + init_call_entry(locator, &call); call.id = CH_STARTPREFIXMAPPING; call.arg1W = SysAllocStringLen(prefix, prefix_len); @@ -1177,6 +1180,8 @@ static HRESULT WINAPI contentHandler_endPrefixMapping( { struct call_entry call; + ok(prefix != NULL, "prefix == NULL\n"); + init_call_entry(locator, &call); call.id = CH_ENDPREFIXMAPPING; call.arg1W = SysAllocStringLen(prefix, len); @@ -1197,6 +1202,10 @@ static HRESULT WINAPI contentHandler_startElement( HRESULT hr; int len; + ok(uri != NULL, "uri == NULL\n"); + ok(localname != NULL, "localname == NULL\n"); + ok(qname != NULL, "qname == NULL\n"); + hr = ISAXAttributes_QueryInterface(saxattr, &IID_IMXAttributes, (void**)&mxattr); EXPECT_HR(hr, E_NOINTERFACE); @@ -1272,6 +1281,10 @@ static HRESULT WINAPI contentHandler_endElement( { struct call_entry call; + ok(uri != NULL, "uri == NULL\n"); + ok(localname != NULL, "localname == NULL\n"); + ok(qname != NULL, "qname == NULL\n"); + init_call_entry(locator, &call); call.id = CH_ENDELEMENT; call.arg1W = SysAllocStringLen(uri, uri_len); @@ -1289,6 +1302,8 @@ static HRESULT WINAPI contentHandler_characters( { struct call_entry call; + ok(chars != NULL, "chars == NULL\n"); + init_call_entry(locator, &call); call.id = CH_CHARACTERS; call.arg1W = SysAllocStringLen(chars, len); @@ -1303,6 +1318,8 @@ static HRESULT WINAPI contentHandler_ignorableWhitespace( { struct call_entry call; + ok(chars != NULL, "chars == NULL\n"); + init_call_entry(locator, &call); call.id = CH_IGNORABLEWHITESPACE; call.arg1W = SysAllocStringLen(chars, len); @@ -1318,6 +1335,9 @@ static HRESULT WINAPI contentHandler_processingInstruction( { struct call_entry call; + ok(target != NULL, "target == NULL\n"); + ok(data != NULL, "data == NULL\n"); + init_call_entry(locator, &call); call.id = CH_PROCESSINGINSTRUCTION; call.arg1W = SysAllocStringLen(target, target_len); @@ -1333,6 +1353,8 @@ static HRESULT WINAPI contentHandler_skippedEntity( { struct call_entry call; + ok(name != NULL, "name == NULL\n"); + init_call_entry(locator, &call); call.id = CH_SKIPPEDENTITY; call.arg1W = SysAllocStringLen(name, len);