From da6a862e76b0b3dcb297c22b83c9b9f6499b7009 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Fri, 25 Jul 2003 14:56:25 +0000 Subject: [PATCH] Bug 211270 InMemoryDataSource::Init doesn't check the return value of PL_DHashTableInit r=tingley sr=dbaron --- rdf/base/src/nsInMemoryDataSource.cpp | 47 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/rdf/base/src/nsInMemoryDataSource.cpp b/rdf/base/src/nsInMemoryDataSource.cpp index 5a9586315713..66aa0c8d5646 100644 --- a/rdf/base/src/nsInMemoryDataSource.cpp +++ b/rdf/base/src/nsInMemoryDataSource.cpp @@ -888,6 +888,8 @@ InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter) #ifdef MOZ_THREADSAFE_RDF mLock = nsnull; #endif + mForwardArcs.ops = nsnull; + mReverseArcs.ops = nsnull; mPropagateChanges = PR_TRUE; } @@ -895,17 +897,22 @@ InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter) nsresult InMemoryDataSource::Init() { - PL_DHashTableInit(&mForwardArcs, - PL_DHashGetStubOps(), - nsnull, - sizeof(Entry), - PL_DHASH_MIN_SIZE); - - PL_DHashTableInit(&mReverseArcs, - PL_DHashGetStubOps(), - nsnull, - sizeof(Entry), - PL_DHASH_MIN_SIZE); + if (!PL_DHashTableInit(&mForwardArcs, + PL_DHashGetStubOps(), + nsnull, + sizeof(Entry), + PL_DHASH_MIN_SIZE)) { + mForwardArcs.ops = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + if (!PL_DHashTableInit(&mReverseArcs, + PL_DHashGetStubOps(), + nsnull, + sizeof(Entry), + PL_DHASH_MIN_SIZE)) { + mReverseArcs.ops = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } #ifdef MOZ_THREADSAFE_RDF mLock = PR_NewLock(); @@ -929,14 +936,16 @@ InMemoryDataSource::~InMemoryDataSource() fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount); #endif - // This'll release all of the Assertion objects that are - // associated with this data source. We only need to do this - // for the forward arcs, because the reverse arcs table - // indexes the exact same set of resources. - PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, &mAllocator); - PL_DHashTableFinish(&mForwardArcs); - - PL_DHashTableFinish(&mReverseArcs); + if (mForwardArcs.ops) { + // This'll release all of the Assertion objects that are + // associated with this data source. We only need to do this + // for the forward arcs, because the reverse arcs table + // indexes the exact same set of resources. + PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, &mAllocator); + PL_DHashTableFinish(&mForwardArcs); + } + if (mReverseArcs.ops) + PL_DHashTableFinish(&mReverseArcs); PR_LOG(gLog, PR_LOG_ALWAYS, ("InMemoryDataSource(%p): destroyed.", this));