mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:54:13 +00:00
msxml3: Simplify IXMLDOMElement_get_tagName(), add null check.
This commit is contained in:
parent
6164ce2d82
commit
d013991d55
2 changed files with 13 additions and 18 deletions
|
@ -489,32 +489,24 @@ static HRESULT WINAPI domelem_get_tagName(
|
|||
{
|
||||
domelem *This = impl_from_IXMLDOMElement( iface );
|
||||
xmlNodePtr element;
|
||||
DWORD len;
|
||||
DWORD offset = 0;
|
||||
LPWSTR str;
|
||||
const xmlChar *prefix;
|
||||
xmlChar *qname;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, p );
|
||||
|
||||
if (!p) return E_INVALIDARG;
|
||||
|
||||
element = get_element( This );
|
||||
if ( !element )
|
||||
return E_FAIL;
|
||||
|
||||
len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, NULL, 0 );
|
||||
if (element->ns)
|
||||
len += MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, NULL, 0 );
|
||||
str = heap_alloc( len * sizeof (WCHAR) );
|
||||
if ( !str )
|
||||
return E_OUTOFMEMORY;
|
||||
if (element->ns)
|
||||
{
|
||||
offset = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, str, len );
|
||||
str[offset - 1] = ':';
|
||||
}
|
||||
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, str + offset, len - offset );
|
||||
*p = SysAllocString( str );
|
||||
heap_free( str );
|
||||
prefix = element->ns ? element->ns->prefix : NULL;
|
||||
qname = xmlBuildQName(element->name, prefix, NULL, 0);
|
||||
|
||||
return S_OK;
|
||||
*p = bstr_from_xmlChar(qname);
|
||||
if (qname != element->name) xmlFree(qname);
|
||||
|
||||
return *p ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI domelem_getAttribute(
|
||||
|
|
|
@ -639,6 +639,9 @@ static void test_domdoc( void )
|
|||
r = IXMLDOMElement_QueryInterface( element, &IID_IObjectIdentity, (LPVOID*)&ident );
|
||||
ok( r == E_NOINTERFACE, "ret %08x\n", r);
|
||||
|
||||
r = IXMLDOMElement_get_tagName( element, NULL );
|
||||
ok( r == E_INVALIDARG, "ret %08x\n", r);
|
||||
|
||||
/* check if the tag is correct */
|
||||
r = IXMLDOMElement_get_tagName( element, &tag );
|
||||
ok( r == S_OK, "couldn't get tag name\n");
|
||||
|
|
Loading…
Reference in a new issue