msxml3/xmldoc: Don't leak document and stream on next IXMLDocument::Load().
This commit is contained in:
parent
6c1275a57c
commit
1cad1646e5
|
@ -431,6 +431,14 @@ static void test_persiststreaminit(void)
|
|||
hr = IPersistStreamInit_IsDirty(psi);
|
||||
todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
|
||||
create_stream_on_file(&stream, path);
|
||||
hr = IPersistStreamInit_Load(psi, stream);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
IStream_Release(stream);
|
||||
|
||||
hr = IPersistStreamInit_IsDirty(psi);
|
||||
todo_wine ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
|
||||
|
||||
/* reset internal stream */
|
||||
hr = IPersistStreamInit_InitNew(psi);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
|
|
@ -616,6 +616,8 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
|
|||
if (!pStm)
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* release previously allocated stream */
|
||||
if (This->stream) IStream_Release(This->stream);
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &This->stream);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
@ -639,7 +641,10 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
|
|||
len = GlobalSize(hglobal);
|
||||
ptr = GlobalLock(hglobal);
|
||||
if (len != 0)
|
||||
{
|
||||
xmlFreeDoc(This->xmldoc);
|
||||
This->xmldoc = parse_xml(ptr, len);
|
||||
}
|
||||
GlobalUnlock(hglobal);
|
||||
|
||||
if (!This->xmldoc)
|
||||
|
@ -648,6 +653,7 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (This->root) IXMLElement_Release(This->root);
|
||||
xmlnode = xmlDocGetRootElement(This->xmldoc);
|
||||
return XMLElement_create((IUnknown *)This, xmlnode, (LPVOID *)&This->root);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue