From 2a9d8007c6654eb6c2c2c4fec6a4ad25cbe066af Mon Sep 17 00:00:00 2001 From: "suresh%netscape.com" Date: Fri, 21 Jun 2002 20:14:12 +0000 Subject: [PATCH] fix for bugscape 16611. crash in InMemoryDataSource::Assert. Checks for obs pointer before calling the app. function. r=rjc, sr=alecf. --- rdf/base/src/nsInMemoryDataSource.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rdf/base/src/nsInMemoryDataSource.cpp b/rdf/base/src/nsInMemoryDataSource.cpp index 28ee306c72b..802a23291b2 100644 --- a/rdf/base/src/nsInMemoryDataSource.cpp +++ b/rdf/base/src/nsInMemoryDataSource.cpp @@ -1386,6 +1386,12 @@ InMemoryDataSource::Assert(nsIRDFResource* aSource, // notify observers for (PRInt32 i = (PRInt32)mNumObservers - 1; i >= 0; --i) { nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i); + + // XXX this should never happen, but it does, and we can't figure out why. + NS_ASSERTION(obs != nsnull, "observer array corrupted!"); + if (! obs) + continue; + obs->OnAssert(this, aSource, aProperty, aTarget); NS_RELEASE(obs); // XXX ignore return value? @@ -1533,6 +1539,12 @@ InMemoryDataSource::Unassert(nsIRDFResource* aSource, // Notify the world for (PRInt32 i = PRInt32(mNumObservers) - 1; i >= 0; --i) { nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i); + + // XXX this should never happen, but it does, and we can't figure out why. + NS_ASSERTION(obs != nsnull, "observer array corrupted!"); + if (! obs) + continue; + obs->OnUnassert(this, aSource, aProperty, aTarget); NS_RELEASE(obs); // XXX ignore return value? @@ -1582,6 +1594,12 @@ InMemoryDataSource::Change(nsIRDFResource* aSource, // Notify the world for (PRInt32 i = PRInt32(mNumObservers) - 1; i >= 0; --i) { nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i); + + // XXX this should never happen, but it does, and we can't figure out why. + NS_ASSERTION(obs != nsnull, "observer array corrupted!"); + if (! obs) + continue; + obs->OnChange(this, aSource, aProperty, aOldTarget, aNewTarget); NS_RELEASE(obs); // XXX ignore return value? @@ -1631,6 +1649,12 @@ InMemoryDataSource::Move(nsIRDFResource* aOldSource, // Notify the world for (PRInt32 i = PRInt32(mNumObservers) - 1; i >= 0; --i) { nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i); + + // XXX this should never happen, but it does, and we can't figure out why. + NS_ASSERTION(obs != nsnull, "observer array corrupted!"); + if (! obs) + continue; + obs->OnMove(this, aOldSource, aNewSource, aProperty, aTarget); NS_RELEASE(obs); // XXX ignore return value?