mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 155413 nsIClassInfo crash [@nsGenericFactory::GetHelperForLanguage] mInfo is null
r=dougt sr=dveditz
This commit is contained in:
parent
ab0cfe7235
commit
525d336040
@ -71,11 +71,11 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsGenericFactory,
|
||||
NS_IMETHODIMP nsGenericFactory::CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (mInfo->mConstructor) {
|
||||
return mInfo->mConstructor(aOuter, aIID, aResult);
|
||||
if (!mInfo || !mInfo->mConstructor) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
return mInfo->mConstructor(aOuter, aIID, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::LockFactory(PRBool aLock)
|
||||
@ -87,7 +87,7 @@ NS_IMETHODIMP nsGenericFactory::LockFactory(PRBool aLock)
|
||||
NS_IMETHODIMP nsGenericFactory::GetInterfaces(PRUint32 *countp,
|
||||
nsIID* **array)
|
||||
{
|
||||
if (!mInfo->mGetInterfacesProc) {
|
||||
if (!mInfo || !mInfo->mGetInterfacesProc) {
|
||||
*countp = 0;
|
||||
*array = nsnull;
|
||||
return NS_OK;
|
||||
@ -98,7 +98,7 @@ NS_IMETHODIMP nsGenericFactory::GetInterfaces(PRUint32 *countp,
|
||||
NS_IMETHODIMP nsGenericFactory::GetHelperForLanguage(PRUint32 language,
|
||||
nsISupports **helper)
|
||||
{
|
||||
if (mInfo->mGetLanguageHelperProc)
|
||||
if (mInfo && mInfo->mGetLanguageHelperProc)
|
||||
return mInfo->mGetLanguageHelperProc(language, helper);
|
||||
*helper = nsnull;
|
||||
return NS_OK;
|
||||
@ -106,44 +106,42 @@ NS_IMETHODIMP nsGenericFactory::GetHelperForLanguage(PRUint32 language,
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetContractID(char **aContractID)
|
||||
{
|
||||
if (mInfo->mContractID) {
|
||||
*aContractID = (char *)nsMemory::Alloc(strlen(mInfo->mContractID) + 1);
|
||||
if (!*aContractID)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
strcpy(*aContractID, mInfo->mContractID);
|
||||
} else {
|
||||
*aContractID = nsnull;
|
||||
}
|
||||
const char *contractID = NS_GENERICFACTORY_CONTRACTID;
|
||||
if (mInfo && mInfo->mContractID)
|
||||
contractID = mInfo->mContractID;
|
||||
*aContractID = nsMemory::Clone(contractID, strlen(contractID) + 1);
|
||||
if (!*aContractID)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetClassDescription(char * *aClassDescription)
|
||||
{
|
||||
if (mInfo->mDescription) {
|
||||
*aClassDescription = (char *)
|
||||
nsMemory::Alloc(strlen(mInfo->mDescription) + 1);
|
||||
if (!*aClassDescription)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
strcpy(*aClassDescription, mInfo->mDescription);
|
||||
} else {
|
||||
*aClassDescription = nsnull;
|
||||
}
|
||||
const char* description =
|
||||
"The prototypical implementation for a `factory' class, "
|
||||
"that is, a class used to produce instance objects";
|
||||
if (mInfo && mInfo->mDescription)
|
||||
description=mInfo->mDescription;
|
||||
*aClassDescription = nsMemory::Clone(description, strlen(description) + 1);
|
||||
if (!*aClassDescription)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetClassID(nsCID * *aClassID)
|
||||
{
|
||||
*aClassID =
|
||||
NS_REINTERPRET_CAST(nsCID*,
|
||||
nsMemory::Clone(&mInfo->mCID, sizeof mInfo->mCID));
|
||||
if (! *aClassID)
|
||||
*aClassID = NS_REINTERPRET_CAST(nsCID*, nsMemory::Alloc(sizeof(nsCID)));
|
||||
if (!*aClassID)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
return GetClassIDNoAlloc(*aClassID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetClassIDNoAlloc(nsCID *aClassID)
|
||||
{
|
||||
*aClassID = mInfo->mCID;
|
||||
if (mInfo)
|
||||
*aClassID = mInfo->mCID;
|
||||
else
|
||||
*aClassID = GetCID();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -155,6 +153,9 @@ NS_IMETHODIMP nsGenericFactory::GetImplementationLanguage(PRUint32 *langp)
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetFlags(PRUint32 *flagsp)
|
||||
{
|
||||
if (!mInfo)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*flagsp = mInfo->mFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -179,18 +180,15 @@ NS_IMETHODIMP nsGenericFactory::GetComponentInfo(const nsModuleComponentInfo **i
|
||||
NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||
{
|
||||
// sorry, aggregation not spoken here.
|
||||
nsresult res = NS_ERROR_NO_AGGREGATION;
|
||||
if (outer == NULL) {
|
||||
nsGenericFactory* factory = new nsGenericFactory;
|
||||
if (factory != NULL) {
|
||||
res = factory->QueryInterface(aIID, aInstancePtr);
|
||||
if (res != NS_OK)
|
||||
delete factory;
|
||||
} else {
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
if (outer)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
nsGenericFactory* factory = new nsGenericFactory;
|
||||
if (!factory)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv = factory->QueryInterface(aIID, aInstancePtr);
|
||||
if (NS_FAILED(rv))
|
||||
delete factory;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
@ -199,7 +197,7 @@ NS_NewGenericFactory(nsIGenericFactory* *result,
|
||||
{
|
||||
nsresult rv;
|
||||
nsIGenericFactory* fact;
|
||||
rv = nsGenericFactory::Create(NULL, NS_GET_IID(nsIGenericFactory), (void**)&fact);
|
||||
rv = nsGenericFactory::Create(nsnull, NS_GET_IID(nsIGenericFactory), (void**)&fact);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = fact->SetComponentInfo(info);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
@ -337,7 +335,7 @@ nsGenericModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
if (!r_classObj) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*r_classObj = NULL;
|
||||
*r_classObj = nsnull;
|
||||
|
||||
// Do one-time-only initialization if necessary
|
||||
if (!mInitialized) {
|
||||
@ -483,7 +481,6 @@ NS_NewGenericModule2(nsModuleInfo* info, nsIModule* *result)
|
||||
rv = m->QueryInterface(NS_GET_IID(nsIModule), (void**)result);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete m;
|
||||
m = nsnull;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user