Fix IXMLDOMDocument error handling.

This commit is contained in:
Stefan Huehner 2005-10-26 10:09:22 +00:00 committed by Alexandre Julliard
parent 0518c164ca
commit 927ba076f1
2 changed files with 20 additions and 1 deletions

View File

@ -727,8 +727,10 @@ static HRESULT WINAPI domdoc_load(
return S_FALSE;
xmldoc = doread( filename );
if ( !xmldoc )
if ( !xmldoc ) {
*isSuccessful = VARIANT_FALSE;
return S_FALSE;
}
This->node = create_node( (xmlNodePtr) xmldoc );
if ( !This->node )

View File

@ -61,6 +61,10 @@ static const WCHAR szComplete4[] = {
'f','n','2','.','t','x','t','<','/','p','r','>',
'<','/','l','c','>','\n',0
};
static const WCHAR szNonExistentFile[] = {
'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
};
static const WCHAR szOpen[] = { 'o','p','e','n',0 };
static const WCHAR szdl[] = { 'd','l',0 };
static const WCHAR szlc[] = { 'l','c',0 };
@ -77,6 +81,7 @@ void test_domdoc( void )
IXMLDOMDocument *doc = NULL;
IXMLDOMElement *element = NULL;
VARIANT_BOOL b;
VARIANT var;
BSTR str;
r = CoCreateInstance( &CLSID_DOMDocument, NULL,
@ -93,6 +98,18 @@ void test_domdoc( void )
ok( r == S_FALSE, "loadXML failed\n");
ok( b == VARIANT_FALSE, "failed to load XML string\n");
/* try to laod an document from an non-existent file */
b = VARIANT_TRUE;
str = SysAllocString ( szNonExistentFile );
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = str;
r = IXMLDOMDocument_load( doc, var, &b);
ok( r == S_FALSE, "load (from file) failed\n");
ok( b == VARIANT_FALSE, "failed to load XML file\n");
SysFreeString( str );
/* try load an empty document */
b = VARIANT_TRUE;
str = SysAllocString( szEmpty );