msxml3: Fix handling of NULL object site (Coverity).

This commit is contained in:
Nikolay Sivov 2012-11-28 13:11:19 -05:00 committed by Alexandre Julliard
parent 21be19a1dc
commit b2643d3841
2 changed files with 21 additions and 15 deletions

View File

@ -1444,34 +1444,37 @@ static HRESULT WINAPI httprequest_ObjectWithSite_GetSite( IObjectWithSite *iface
static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk )
{
httprequest *This = impl_from_IObjectWithSite(iface);
IServiceProvider *provider;
HRESULT hr;
TRACE("(%p)->(%p)\n", iface, punk);
if (punk)
IUnknown_AddRef( punk );
TRACE("(%p)->(%p)\n", This, punk);
if(This->site)
IUnknown_Release( This->site );
SysFreeString(This->siteurl);
This->siteurl = NULL;
This->site = punk;
hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
if (hr == S_OK)
if (punk)
{
IHTMLDocument2 *doc;
IServiceProvider *provider;
HRESULT hr;
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
IUnknown_AddRef( punk );
hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
if (hr == S_OK)
{
SysFreeString(This->siteurl);
IHTMLDocument2 *doc;
hr = IHTMLDocument2_get_URL(doc, &This->siteurl);
IHTMLDocument2_Release(doc);
TRACE("host url %s, 0x%08x\n", debugstr_w(This->siteurl), hr);
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
if (hr == S_OK)
{
hr = IHTMLDocument2_get_URL(doc, &This->siteurl);
IHTMLDocument2_Release(doc);
TRACE("host url %s, 0x%08x\n", debugstr_w(This->siteurl), hr);
}
IServiceProvider_Release(provider);
}
IServiceProvider_Release(provider);
}
return S_OK;

View File

@ -5213,6 +5213,9 @@ todo_wine {
EXPECT_REF(obj_site, 1);
}
hr = IObjectWithSite_SetSite(obj_site, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
IObjectWithSite_AddRef(obj_site);
todo_wine {
EXPECT_REF(obj_site, 2);