msxml3: Null pointer for schema uri should be treated as empty.

This commit is contained in:
Nikolay Sivov 2011-02-17 01:42:15 +03:00 committed by Alexandre Julliard
parent 21332ccb85
commit edeff310b1
2 changed files with 46 additions and 8 deletions

View File

@ -63,11 +63,13 @@ static const xmlChar XDR_schema[] = "Schema";
static const xmlChar XDR_nsURI[] = "urn:schemas-microsoft-com:xml-data";
static const xmlChar DT_nsURI[] = "urn:schemas-microsoft-com:datatypes";
static xmlChar const* datatypes_src = NULL;
static int datatypes_len = 0;
static HGLOBAL datatypes_handle = NULL;
static HRSRC datatypes_rsrc = NULL;
static xmlSchemaPtr datatypes_schema = NULL;
static xmlChar const* datatypes_src;
static int datatypes_len;
static HGLOBAL datatypes_handle;
static HRSRC datatypes_rsrc;
static xmlSchemaPtr datatypes_schema;
static const WCHAR emptyW[] = {0};
/* Supported Types:
* msxml3 - XDR only
@ -1057,7 +1059,7 @@ static HRESULT WINAPI schema_cache_Invoke(IXMLDOMSchemaCollection2* iface,
static HRESULT WINAPI schema_cache_add(IXMLDOMSchemaCollection2* iface, BSTR uri, VARIANT var)
{
schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
xmlChar* name = xmlChar_from_wchar(uri);
xmlChar* name = uri ? xmlChar_from_wchar(uri) : xmlChar_from_wchar(emptyW);
TRACE("(%p)->(%s, var(vt %x))\n", This, debugstr_w(uri), V_VT(&var));
switch (V_VT(&var))
@ -1158,7 +1160,7 @@ static HRESULT WINAPI schema_cache_get(IXMLDOMSchemaCollection2* iface, BSTR uri
if (!node)
return E_POINTER;
name = xmlChar_from_wchar(uri);
name = uri ? xmlChar_from_wchar(uri) : xmlChar_from_wchar(emptyW);
entry = (cache_entry*) xmlHashLookup(This->cache, name);
heap_free(name);
@ -1173,7 +1175,7 @@ static HRESULT WINAPI schema_cache_get(IXMLDOMSchemaCollection2* iface, BSTR uri
static HRESULT WINAPI schema_cache_remove(IXMLDOMSchemaCollection2* iface, BSTR uri)
{
schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
xmlChar* name = xmlChar_from_wchar(uri);
xmlChar* name = uri ? xmlChar_from_wchar(uri) : xmlChar_from_wchar(emptyW);
TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(uri));
xmlHashRemoveEntry(This->cache, name, cache_free);

View File

@ -493,11 +493,14 @@ static void* _create_object(const GUID *clsid, const char *name, const IID *iid,
static void test_schema_refs(void)
{
static const WCHAR emptyW[] = {0};
IXMLDOMDocument2 *doc;
IXMLDOMNode *node;
IXMLDOMSchemaCollection *cache;
VARIANT v;
VARIANT_BOOL b;
BSTR str;
LONG len;
doc = create_document(&IID_IXMLDOMDocument2);
if (!doc)
@ -516,6 +519,39 @@ static void test_schema_refs(void)
ok(b == VARIANT_TRUE, "b %04x\n", b);
SysFreeString(str);
node = (void*)0xdeadbeef;
ole_check(IXMLDOMSchemaCollection_get(cache, NULL, &node));
ok(node == NULL, "%p\n", node);
/* NULL uri pointer, still adds a document */
ole_check(IXMLDOMSchemaCollection_add(cache, NULL, _variantdoc_(doc)));
len = -1;
ole_check(IXMLDOMSchemaCollection_get_length(cache, &len));
ok(len == 1, "got %d\n", len);
/* read back - empty valid BSTR */
str = NULL;
ole_check(IXMLDOMSchemaCollection_get_namespaceURI(cache, 0, &str));
ok(str && *str == 0, "got %p\n", str);
SysFreeString(str);
node = NULL;
ole_check(IXMLDOMSchemaCollection_get(cache, NULL, &node));
ok(node != NULL, "%p\n", node);
IXMLDOMNode_Release(node);
node = NULL;
str = SysAllocString(emptyW);
ole_check(IXMLDOMSchemaCollection_get(cache, str, &node));
ok(node != NULL, "%p\n", node);
IXMLDOMNode_Release(node);
SysFreeString(str);
/* remove with NULL uri */
ole_check(IXMLDOMSchemaCollection_remove(cache, NULL));
len = -1;
ole_check(IXMLDOMSchemaCollection_get_length(cache, &len));
ok(len == 0, "got %d\n", len);
str = SysAllocString(xdr_schema_uri);
ole_check(IXMLDOMSchemaCollection_add(cache, str, _variantdoc_(doc)));