Bug 211270 InMemoryDataSource::Init doesn't check the return value of PL_DHashTableInit

r=tingley sr=dbaron
This commit is contained in:
timeless%mozdev.org 2003-07-25 14:56:25 +00:00
Родитель 3eb7244d66
Коммит da6a862e76
1 изменённых файлов: 28 добавлений и 19 удалений

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

@ -888,6 +888,8 @@ InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter)
#ifdef MOZ_THREADSAFE_RDF #ifdef MOZ_THREADSAFE_RDF
mLock = nsnull; mLock = nsnull;
#endif #endif
mForwardArcs.ops = nsnull;
mReverseArcs.ops = nsnull;
mPropagateChanges = PR_TRUE; mPropagateChanges = PR_TRUE;
} }
@ -895,17 +897,22 @@ InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter)
nsresult nsresult
InMemoryDataSource::Init() InMemoryDataSource::Init()
{ {
PL_DHashTableInit(&mForwardArcs, if (!PL_DHashTableInit(&mForwardArcs,
PL_DHashGetStubOps(), PL_DHashGetStubOps(),
nsnull, nsnull,
sizeof(Entry), sizeof(Entry),
PL_DHASH_MIN_SIZE); PL_DHASH_MIN_SIZE)) {
mForwardArcs.ops = nsnull;
PL_DHashTableInit(&mReverseArcs, return NS_ERROR_OUT_OF_MEMORY;
PL_DHashGetStubOps(), }
nsnull, if (!PL_DHashTableInit(&mReverseArcs,
sizeof(Entry), PL_DHashGetStubOps(),
PL_DHASH_MIN_SIZE); nsnull,
sizeof(Entry),
PL_DHASH_MIN_SIZE)) {
mReverseArcs.ops = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
#ifdef MOZ_THREADSAFE_RDF #ifdef MOZ_THREADSAFE_RDF
mLock = PR_NewLock(); mLock = PR_NewLock();
@ -929,14 +936,16 @@ InMemoryDataSource::~InMemoryDataSource()
fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount); fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount);
#endif #endif
// This'll release all of the Assertion objects that are if (mForwardArcs.ops) {
// associated with this data source. We only need to do this // This'll release all of the Assertion objects that are
// for the forward arcs, because the reverse arcs table // associated with this data source. We only need to do this
// indexes the exact same set of resources. // for the forward arcs, because the reverse arcs table
PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, &mAllocator); // indexes the exact same set of resources.
PL_DHashTableFinish(&mForwardArcs); PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, &mAllocator);
PL_DHashTableFinish(&mForwardArcs);
PL_DHashTableFinish(&mReverseArcs); }
if (mReverseArcs.ops)
PL_DHashTableFinish(&mReverseArcs);
PR_LOG(gLog, PR_LOG_ALWAYS, PR_LOG(gLog, PR_LOG_ALWAYS,
("InMemoryDataSource(%p): destroyed.", this)); ("InMemoryDataSource(%p): destroyed.", this));