Commit afb17f29 authored by Michael Karcher's avatar Michael Karcher Committed by Alexandre Julliard

msxml3: attach_xmldoc may fail.

The upcoming new implementation of attach_xmldoc needs HeapAlloc. Prepare for the failure case.
parent 8b293040
...@@ -209,7 +209,7 @@ HRESULT xmldoc_remove_orphan(xmlDocPtr doc, xmlNodePtr node) ...@@ -209,7 +209,7 @@ HRESULT xmldoc_remove_orphan(xmlDocPtr doc, xmlNodePtr node)
return S_FALSE; return S_FALSE;
} }
static void attach_xmldoc( IXMLDOMNode *node, xmlDocPtr xml ) static HRESULT attach_xmldoc( IXMLDOMNode *node, xmlDocPtr xml )
{ {
xmlnode *This = impl_from_IXMLDOMNode( node ); xmlnode *This = impl_from_IXMLDOMNode( node );
...@@ -220,7 +220,7 @@ static void attach_xmldoc( IXMLDOMNode *node, xmlDocPtr xml ) ...@@ -220,7 +220,7 @@ static void attach_xmldoc( IXMLDOMNode *node, xmlDocPtr xml )
if(This->node) if(This->node)
xmldoc_add_ref(This->node->doc); xmldoc_add_ref(This->node->doc);
return; return S_OK;
} }
static inline domdoc *impl_from_IXMLDOMDocument2( IXMLDOMDocument2 *iface ) static inline domdoc *impl_from_IXMLDOMDocument2( IXMLDOMDocument2 *iface )
...@@ -345,9 +345,8 @@ static HRESULT WINAPI xmldoc_IPersistStream_Load( ...@@ -345,9 +345,8 @@ static HRESULT WINAPI xmldoc_IPersistStream_Load(
} }
xmldoc->_private = create_priv(); xmldoc->_private = create_priv();
attach_xmldoc( This->node, xmldoc );
return S_OK; return attach_xmldoc( This->node, xmldoc );
} }
static HRESULT WINAPI xmldoc_IPersistStream_Save( static HRESULT WINAPI xmldoc_IPersistStream_Save(
...@@ -1324,7 +1323,7 @@ static HRESULT domdoc_onDataAvailable(void *obj, char *ptr, DWORD len) ...@@ -1324,7 +1323,7 @@ static HRESULT domdoc_onDataAvailable(void *obj, char *ptr, DWORD len)
xmldoc = doparse( ptr, len ); xmldoc = doparse( ptr, len );
if(xmldoc) { if(xmldoc) {
xmldoc->_private = create_priv(); xmldoc->_private = create_priv();
attach_xmldoc(This->node, xmldoc); return attach_xmldoc(This->node, xmldoc);
} }
return S_OK; return S_OK;
...@@ -1377,11 +1376,12 @@ static HRESULT WINAPI domdoc_load( ...@@ -1377,11 +1376,12 @@ static HRESULT WINAPI domdoc_load(
{ {
domdoc *newDoc = impl_from_IXMLDOMDocument2( pNewDoc ); domdoc *newDoc = impl_from_IXMLDOMDocument2( pNewDoc );
xmldoc = xmlCopyDoc(get_doc(newDoc), 1); xmldoc = xmlCopyDoc(get_doc(newDoc), 1);
attach_xmldoc(This->node, xmldoc); hr = attach_xmldoc(This->node, xmldoc);
*isSuccessful = VARIANT_TRUE; if(SUCCEEDED(hr))
*isSuccessful = VARIANT_TRUE;
return S_OK; return hr;
} }
} }
hr = IUnknown_QueryInterface(V_UNKNOWN(&xmlSource), &IID_IStream, (void**)&pStream); hr = IUnknown_QueryInterface(V_UNKNOWN(&xmlSource), &IID_IStream, (void**)&pStream);
...@@ -1438,8 +1438,9 @@ static HRESULT WINAPI domdoc_load( ...@@ -1438,8 +1438,9 @@ static HRESULT WINAPI domdoc_load(
if(!filename || FAILED(hr)) { if(!filename || FAILED(hr)) {
xmldoc = xmlNewDoc(NULL); xmldoc = xmlNewDoc(NULL);
xmldoc->_private = create_priv(); xmldoc->_private = create_priv();
attach_xmldoc(This->node, xmldoc); hr = attach_xmldoc(This->node, xmldoc);
hr = S_FALSE; if(SUCCEEDED(hr))
hr = S_FALSE;
} }
TRACE("ret (%d)\n", hr); TRACE("ret (%d)\n", hr);
...@@ -1541,7 +1542,7 @@ static HRESULT WINAPI domdoc_loadXML( ...@@ -1541,7 +1542,7 @@ static HRESULT WINAPI domdoc_loadXML(
xmlDocPtr xmldoc = NULL; xmlDocPtr xmldoc = NULL;
char *str; char *str;
int len; int len;
HRESULT hr = S_FALSE; HRESULT hr = S_FALSE, hr2;
TRACE("%p %s %p\n", This, debugstr_w( bstrXML ), isSuccessful ); TRACE("%p %s %p\n", This, debugstr_w( bstrXML ), isSuccessful );
...@@ -1568,7 +1569,9 @@ static HRESULT WINAPI domdoc_loadXML( ...@@ -1568,7 +1569,9 @@ static HRESULT WINAPI domdoc_loadXML(
xmldoc = xmlNewDoc(NULL); xmldoc = xmlNewDoc(NULL);
xmldoc->_private = create_priv(); xmldoc->_private = create_priv();
attach_xmldoc( This->node, xmldoc ); hr2 = attach_xmldoc( This->node, xmldoc );
if( FAILED(hr2) )
hr = hr2;
return hr; return hr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment