From 940379bb25c9b6e7170769a2c1003029030ed1ca Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Thu, 4 Apr 2002 21:35:32 +0000 Subject: [PATCH] Fixes 132705. nsComponentManagerUtils error handling is incorrect. fix by dbaron, r=dougt, sr=rpotts, a=asa@mozilla.org --- xpcom/glue/nsComponentManagerUtils.cpp | 30 ++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/xpcom/glue/nsComponentManagerUtils.cpp b/xpcom/glue/nsComponentManagerUtils.cpp index 6052ee6ddb4..d560fb9ca7f 100644 --- a/xpcom/glue/nsComponentManagerUtils.cpp +++ b/xpcom/glue/nsComponentManagerUtils.cpp @@ -50,13 +50,12 @@ nsresult nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const { nsCOMPtr compMgr; - NS_GetComponentManager(getter_AddRefs(compMgr)); - if (!compMgr) - return NS_ERROR_FAILURE; - nsresult status = compMgr->CreateInstance(mCID, - mOuter, - aIID, - aInstancePtr); + nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr)); + if (compMgr) + status = compMgr->CreateInstance(mCID, mOuter, aIID, aInstancePtr); + else if (NS_SUCCEEDED(status)) + status = NS_ERROR_UNEXPECTED; + if ( NS_FAILED(status) ) *aInstancePtr = 0; @@ -71,19 +70,18 @@ nsCreateInstanceByContractID::operator()( const nsIID& aIID, void** aInstancePtr nsresult status; if ( mContractID ) { nsCOMPtr compMgr; - NS_GetComponentManager(getter_AddRefs(compMgr)); - if (!compMgr) - return NS_ERROR_FAILURE; - status = compMgr->CreateInstanceByContractID(mContractID, - mOuter, - aIID, - aInstancePtr); - if (NS_FAILED(status)) - *aInstancePtr = 0; + status = NS_GetComponentManager(getter_AddRefs(compMgr)); + if (compMgr) + status = compMgr->CreateInstanceByContractID(mContractID, mOuter, + aIID, aInstancePtr); + else if (NS_SUCCEEDED(status)) + status = NS_ERROR_UNEXPECTED; } else status = NS_ERROR_NULL_POINTER; + if (NS_FAILED(status)) + *aInstancePtr = 0; if ( mErrorPtr ) *mErrorPtr = status; return status;