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.

This commit is contained in:
smfr%smfr.org 2005-11-06 18:31:09 +00:00
Родитель d8196b6b42
Коммит 2254bafe1b
1 изменённых файлов: 17 добавлений и 15 удалений

Просмотреть файл

@ -42,23 +42,25 @@
nsresult
nsGetInterface::operator()( const nsIID& aIID, void** aInstancePtr ) const
{
nsresult status;
nsresult status;
if ( mSource )
{
nsCOMPtr<nsIInterfaceRequestor> 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<nsIInterfaceRequestor> 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;
}