Alistair Leslie-Hughes : msxml3: Corrected getAttributeNode to return correct values.

Alexandre Julliard julliard at winehq.org
Wed Dec 17 09:39:35 CST 2008


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

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Sat Dec 13 20:12:02 2008 +1100

msxml3: Corrected getAttributeNode to return correct values.

---

 dlls/msxml3/element.c      |   15 ++++++++++++---
 dlls/msxml3/tests/domdoc.c |   10 ++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c
index a31f80e..f479395 100644
--- a/dlls/msxml3/element.c
+++ b/dlls/msxml3/element.c
@@ -587,23 +587,32 @@ static HRESULT WINAPI domelem_getAttributeNode(
     xmlNodePtr element;
     xmlAttrPtr attr;
     IUnknown *unk;
-    HRESULT hr = E_FAIL;
+    HRESULT hr = S_FALSE;
 
     TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), attributeNode);
 
+    if(!attributeNode)
+        return E_FAIL;
+
+    *attributeNode = NULL;
+
     element = get_element( This );
     if ( !element )
         return E_FAIL;
 
     xml_name = xmlChar_from_wchar(p);
 
+    if(!xmlValidateNameValue(xml_name))
+    {
+        HeapFree(GetProcessHeap(), 0, xml_name);
+        return E_FAIL;
+    }
+
     attr = xmlHasProp(element, xml_name);
     if(attr) {
         unk = create_attribute((xmlNodePtr)attr);
         hr = IUnknown_QueryInterface(unk, &IID_IXMLDOMAttribute, (void**)attributeNode);
         IUnknown_Release(unk);
-    }else {
-        *attributeNode = NULL;
     }
 
     HeapFree(GetProcessHeap(), 0, xml_name);
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index bac7e3f..73ba932 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -958,12 +958,22 @@ static void test_domnode( void )
         ok( V_VT(&var) == VT_NULL || V_VT(&var) == VT_EMPTY, "vt = %x\n", V_VT(&var));
         VariantClear(&var);
 
+        r = IXMLDOMElement_getAttributeNode( element, str, NULL);
+        ok( r == E_FAIL, "getAttributeNode ret %08x\n", r );
+
         attr = (IXMLDOMAttribute*)0xdeadbeef;
         r = IXMLDOMElement_getAttributeNode( element, str, &attr);
         ok( r == E_FAIL, "getAttributeNode ret %08x\n", r );
         ok( attr == NULL, "getAttributeNode ret %p, expected NULL\n", attr );
         SysFreeString( str );
 
+        attr = (IXMLDOMAttribute*)0xdeadbeef;
+        str = _bstr_("nonExisitingAttribute");
+        r = IXMLDOMElement_getAttributeNode( element, str, &attr);
+        ok( r == S_FALSE, "getAttributeNode ret %08x\n", r );
+        ok( attr == NULL, "getAttributeNode ret %p, expected NULL\n", attr );
+        SysFreeString( str );
+
         str = SysAllocString( szdl );	
         V_VT(&var) = VT_I4;
         V_I4(&var) = 0x1234;




More information about the wine-cvs mailing list