Nikolay Sivov : msxml3: Fix handling of NULL object site (Coverity).
Alexandre Julliard
julliard at winehq.org
Wed Nov 28 14:14:06 CST 2012
Module: wine
Branch: master
Commit: b2643d3841118ea100df1bccc7b2f3148bfc2493
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b2643d3841118ea100df1bccc7b2f3148bfc2493
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Nov 28 13:11:19 2012 -0500
msxml3: Fix handling of NULL object site (Coverity).
---
dlls/msxml3/httprequest.c | 33 ++++++++++++++++++---------------
dlls/msxml3/tests/domdoc.c | 3 +++
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c
index 2600ffe..9d93cca 100644
--- a/dlls/msxml3/httprequest.c
+++ b/dlls/msxml3/httprequest.c
@@ -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;
+
+ IUnknown_AddRef( punk );
- hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
+ 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;
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 3a62c95..d75bb5f 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -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);
More information about the wine-cvs
mailing list