msxml3: Fix IXMLDOMNamedNodeMap_getNamedItem() conformance on error
Dan Hipschman
dsh at linux.ucla.edu
Wed Sep 20 18:41:30 CDT 2006
This fixes a slight conformance problem in getNamedItem. The cases that
need fixing are: (1) when namedItem is NULL we should return E_INVALIDARG
not crash; and (2) if the item isn't found, we should return NULL in
namedItem and return S_FALSE not leave it unchanged and return E_FAIL.
The tests confirm this on XP.
ChangeLog:
* Fix IXMLDOMNamedNodeMap_getNamedItem error conformance.
---
dlls/msxml3/nodemap.c | 10 ++++++++--
dlls/msxml3/tests/domdoc.c | 13 +++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/msxml3/nodemap.c b/dlls/msxml3/nodemap.c
index 32fd32c..0797436 100644
--- a/dlls/msxml3/nodemap.c
+++ b/dlls/msxml3/nodemap.c
@@ -165,7 +165,10 @@ static HRESULT WINAPI xmlnodemap_getName
xmlAttrPtr attr;
xmlNodePtr node;
- TRACE("%p %s\n", This, debugstr_w(name) );
+ TRACE("%p %s %p\n", This, debugstr_w(name), namedItem );
+
+ if ( !namedItem )
+ return E_INVALIDARG;
node = xmlNodePtr_from_domnode( This->node, 0 );
if ( !node )
@@ -176,7 +179,10 @@ static HRESULT WINAPI xmlnodemap_getName
HeapFree( GetProcessHeap(), 0, element_name );
if ( !attr )
- return E_FAIL;
+ {
+ *namedItem = NULL;
+ return S_FALSE;
+ }
*namedItem = create_node( (xmlNodePtr) attr );
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index aaad036..4a3fdc1 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -396,6 +396,19 @@ todo_wine
IXMLDOMNode_Release(node);
SysFreeString( str );
+ str = SysAllocString( szdl );
+ r = IXMLDOMNamedNodeMap_getNamedItem( map, str, NULL );
+ ok( r == E_INVALIDARG, "getNamedItem should return E_INVALIDARG\n");
+ SysFreeString( str );
+
+ /* something that isn't in szComplete4 */
+ str = SysAllocString( szOpen );
+ node = (IXMLDOMNode *) 1;
+ r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
+ ok( r = S_FALSE, "getNamedItem found a node that wasn't there\n");
+ ok( node == NULL, "getNamedItem should have returned NULL\n");
+ SysFreeString( str );
+
/* test indexed access of attributes */
r = IXMLDOMNamedNodeMap_get_length( map, &count );
ok ( r == S_OK, "get_length wrong code\n");
More information about the wine-patches
mailing list