mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 05:10:49 +00:00
check for null before querying the interface
This commit is contained in:
parent
5db6657def
commit
b0094e1e0f
@ -172,10 +172,21 @@ NS_NewArticleList(nsINNTPArticleList **articleList,
|
||||
nsINNTPHost* newsHost,
|
||||
nsINNTPNewsgroup* newsgroup)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsNNTPArticleList* aArticleList =
|
||||
new nsNNTPArticleList(newsHost, newsgroup);
|
||||
return aArticleList->QueryInterface(nsINNTPArticleList::GetIID(),
|
||||
(void **)articleList);
|
||||
|
||||
if (aArticleList)
|
||||
rv = aArticleList->QueryInterface(nsINNTPArticleList::GetIID(),
|
||||
(void **)articleList);
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv) && aArticleList)
|
||||
delete aArticleList;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
@ -74,7 +74,9 @@ nsresult nsNNTPCategoryContainerStub::SetRootCategory(nsINNTPNewsgroup * aRootCa
|
||||
{
|
||||
char * name = nsnull;
|
||||
aRootCategory->GetName(&name);
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("Setting root category for container to %s", name ? name : "unspecified");
|
||||
#endif
|
||||
m_newsgroup = aRootCategory;
|
||||
NS_IF_ADDREF(m_newsgroup);
|
||||
}
|
||||
@ -91,8 +93,17 @@ nsresult NS_NewCategoryContainerFromNewsgroup(nsINNTPCategoryContainer ** aInsta
|
||||
if (aInstancePtr)
|
||||
{
|
||||
stub = new nsNNTPCategoryContainerStub();
|
||||
stub->SetRootCategory(group);
|
||||
rv = stub->QueryInterface(nsINNTPCategoryContainer::GetIID(), (void **) aInstancePtr);
|
||||
if (stub) {
|
||||
stub->SetRootCategory(group);
|
||||
rv = stub->QueryInterface(nsINNTPCategoryContainer::GetIID(), (void **) aInstancePtr);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) && stub) {
|
||||
delete stub;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user