From f7371871dfd69920727e7a7267b137b9c2f08b8c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 22 Feb 2008 02:09:12 +0100 Subject: [PATCH] urlmon: Correctly handle creating object failure. --- dlls/urlmon/binding.c | 57 ++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/dlls/urlmon/binding.c b/dlls/urlmon/binding.c index a966f2ef820..6bd2946e3be 100644 --- a/dlls/urlmon/binding.c +++ b/dlls/urlmon/binding.c @@ -420,31 +420,17 @@ static void load_doc_mon(Binding *binding, IPersistMoniker *persist) FIXME("Load failed: %08x\n", hres); } -static void create_object(Binding *binding) +static HRESULT create_mime_object(Binding *binding, const CLSID *clsid, LPCWSTR clsid_str) { IPersistMoniker *persist; - LPWSTR clsid_str; - CLSID clsid; HRESULT hres; - if(!binding->mime) { - FIXME("MIME unavailable\n"); - return; - } - - if(!(clsid_str = get_mime_clsid(binding->mime, &clsid))) { - FIXME("Could not find object for MIME %s\n", debugstr_w(binding->mime)); - return; - } - - IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_CLASSIDAVAILABLE, clsid_str); - - IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_BEGINSYNCOPERATION, NULL); - - hres = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, + hres = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &binding->iid, (void**)&binding->obj); - if(FAILED(hres)) - FIXME("CoCreateInstance failed: %08x\n", hres); + if(FAILED(hres)) { + WARN("CoCreateInstance failed: %08x\n", hres); + return INET_E_CANNOT_INSTANTIATE_OBJECT; + } binding->state |= BINDING_OBJAVAIL; @@ -467,13 +453,38 @@ static void create_object(Binding *binding) /* FIXME: Try query IPersistFile */ } - heap_free(clsid_str); - IBindStatusCallback_OnObjectAvailable(binding->callback, &binding->iid, binding->obj); + return S_OK; +} + +static void create_object(Binding *binding) +{ + LPWSTR clsid_str; + CLSID clsid; + HRESULT hres; + + if(!binding->mime) { + FIXME("MIME not available\n"); + return; + } + + if(!(clsid_str = get_mime_clsid(binding->mime, &clsid))) { + FIXME("Could not find object for MIME %s\n", debugstr_w(binding->mime)); + return; + } + + IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_CLASSIDAVAILABLE, clsid_str); + IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_BEGINSYNCOPERATION, NULL); + + hres = create_mime_object(binding, &clsid, clsid_str); + heap_free(clsid_str); + IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_ENDSYNCOPERATION, NULL); - stop_binding(binding, S_OK, NULL); + stop_binding(binding, hres, NULL); + if(FAILED(hres)) + IInternetProtocol_Terminate(binding->protocol, 0); } #define STGMEDUNK_THIS(iface) DEFINE_THIS(stgmed_buf_t, Unknown, iface)