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

View File

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