From 2254bafe1bfb7da8df1ac471285a5979e6e883f9 Mon Sep 17 00:00:00 2001 From: "smfr%smfr.org" Date: Sun, 6 Nov 2005 18:31:09 +0000 Subject: [PATCH] Fix bug 315246: nsGetInterface::operator() can use an uninitialized nsresult variable, if the source fails to implement nsIInterfaceRequestor (which fires an assertion in debug builds). r=dougt, sr=bzbarsky. --- xpcom/glue/nsIInterfaceRequestorUtils.cpp | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/xpcom/glue/nsIInterfaceRequestorUtils.cpp b/xpcom/glue/nsIInterfaceRequestorUtils.cpp index b440c3422b7..7d25dc6707f 100644 --- a/xpcom/glue/nsIInterfaceRequestorUtils.cpp +++ b/xpcom/glue/nsIInterfaceRequestorUtils.cpp @@ -42,23 +42,25 @@ nsresult nsGetInterface::operator()( const nsIID& aIID, void** aInstancePtr ) const { - nsresult status; + nsresult status; - if ( mSource ) - { - nsCOMPtr factoryPtr = do_QueryInterface(mSource, &status); - NS_ASSERTION(factoryPtr, "Did you know you were calling |do_GetInterface()| on an object that doesn't support the |nsIInterfaceRequestor| interface?"); + if ( mSource ) + { + nsCOMPtr factoryPtr = do_QueryInterface(mSource, &status); + NS_ASSERTION(factoryPtr, "Did you know you were calling |do_GetInterface()| on an object that doesn't support the |nsIInterfaceRequestor| interface?"); - if ( factoryPtr ) - status = factoryPtr->GetInterface(aIID, aInstancePtr); + if ( factoryPtr ) + status = factoryPtr->GetInterface(aIID, aInstancePtr); + else + status = NS_ERROR_NO_INTERFACE; - if ( NS_FAILED(status) ) - *aInstancePtr = 0; - } - else - status = NS_ERROR_NULL_POINTER; + if ( NS_FAILED(status) ) + *aInstancePtr = 0; + } + else + status = NS_ERROR_NULL_POINTER; - if ( mErrorPtr ) - *mErrorPtr = status; - return status; + if ( mErrorPtr ) + *mErrorPtr = status; + return status; }