Bug 1028588 - Fix dangerous public destructors in rdf/ - r=bsmedberg
☠☠ backed out by 9b33a6d30532 ☠ ☠
authorBenoit Jacob <bjacob@mozilla.com>
Mon, 30 Jun 2014 18:11:50 -0400
changeset 191603 d5fae80054de26783e93ca9948cd358965a874b2
parent 191602 5942ad3859b831032a8afa0ac2e7d6d4deb0b5c7
child 191604 19a19833f1d60e3bed4a16f31cd5ff2f92051bca
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbsmedberg
bugs1028588
milestone33.0a1
Bug 1028588 - Fix dangerous public destructors in rdf/ - r=bsmedberg
rdf/base/src/nsContainerEnumerator.cpp
rdf/base/src/nsInMemoryDataSource.cpp
rdf/base/src/nsRDFContentSink.cpp
rdf/base/src/nsRDFService.cpp
rdf/base/src/nsRDFXMLSerializer.cpp
rdf/base/src/rdfTriplesSerializer.cpp
rdf/datasource/src/nsFileSystemDataSource.h
rdf/tests/rdfcat/rdfcat.cpp
rdf/tests/rdfpoll/rdfpoll.cpp
rdf/tests/triplescat/triplescat.cpp
rdf/util/public/nsRDFResource.h
--- a/rdf/base/src/nsContainerEnumerator.cpp
+++ b/rdf/base/src/nsContainerEnumerator.cpp
@@ -46,19 +46,20 @@ private:
     nsCOMPtr<nsIRDFDataSource>      mDataSource;
     nsCOMPtr<nsIRDFResource>        mContainer;
     nsCOMPtr<nsIRDFResource>        mOrdinalProperty;
 
     nsCOMPtr<nsISimpleEnumerator>   mCurrent;
     nsCOMPtr<nsIRDFNode>            mResult;
     int32_t mNextIndex;
 
+    virtual ~ContainerEnumeratorImpl();
+
 public:
     ContainerEnumeratorImpl(nsIRDFDataSource* ds, nsIRDFResource* container);
-    virtual ~ContainerEnumeratorImpl();
 
     nsresult Init();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISIMPLEENUMERATOR
 };
 
 nsrefcnt              ContainerEnumeratorImpl::gRefCnt;
--- a/rdf/base/src/nsInMemoryDataSource.cpp
+++ b/rdf/base/src/nsInMemoryDataSource.cpp
@@ -386,25 +386,25 @@ private:
     nsIRDFResource* mSource;
     nsIRDFResource* mProperty;
     nsIRDFNode*     mTarget;
     nsIRDFNode*     mValue;
     bool            mTruthValue;
     Assertion*      mNextAssertion;
     nsCOMPtr<nsISupportsArray> mHashArcs;
 
+    virtual ~InMemoryAssertionEnumeratorImpl();
+
 public:
     InMemoryAssertionEnumeratorImpl(InMemoryDataSource* aDataSource,
                                     nsIRDFResource* aSource,
                                     nsIRDFResource* aProperty,
                                     nsIRDFNode* aTarget,
                                     bool aTruthValue);
 
-    virtual ~InMemoryAssertionEnumeratorImpl();
-
     // nsISupports interface
     NS_DECL_ISUPPORTS
 
     // nsISimpleEnumerator interface
     NS_DECL_NSISIMPLEENUMERATOR
 };
 
 ////////////////////////////////////////////////////////////////////////
@@ -558,23 +558,23 @@ private:
     nsIRDFResource*     mCurrent;
     Assertion*          mAssertion;
     nsCOMPtr<nsISupportsArray> mHashArcs;
 
     static PLDHashOperator
     ArcEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr,
                        uint32_t aNumber, void* aArg);
 
+    virtual ~InMemoryArcsEnumeratorImpl();
+
 public:
     InMemoryArcsEnumeratorImpl(InMemoryDataSource* aDataSource,
                                nsIRDFResource* aSource,
                                nsIRDFNode* aTarget);
 
-    virtual ~InMemoryArcsEnumeratorImpl();
-
     // nsISupports interface
     NS_DECL_ISUPPORTS
 
     // nsISimpleEnumerator interface
     NS_DECL_NSISIMPLEENUMERATOR
 };
 
 
--- a/rdf/base/src/nsRDFContentSink.cpp
+++ b/rdf/base/src/nsRDFContentSink.cpp
@@ -97,17 +97,16 @@ NS_STDCALL_FUNCPROTO(nsresult,
                      nsIRDFContainerUtils, MakeAlt,
                      (nsIRDFDataSource*, nsIRDFResource*, nsIRDFContainer**));
 
 class RDFContentSinkImpl : public nsIRDFContentSink,
                            public nsIExpatSink
 {
 public:
     RDFContentSinkImpl();
-    virtual ~RDFContentSinkImpl();
 
     // nsISupports
     NS_DECL_ISUPPORTS
     NS_DECL_NSIEXPATSINK
 
     // nsIContentSink
     NS_IMETHOD WillParse(void);
     NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode);
@@ -141,16 +140,18 @@ public:
 
     typedef struct ContainerInfo {
         nsIRDFResource**  mType;
         nsContainerTestFn mTestFn;
         nsMakeContainerFn mMakeFn;
     } ContainerInfo;
 
 protected:
+    virtual ~RDFContentSinkImpl();
+
     // Text management
     void ParseText(nsIRDFNode **aResult);
 
     nsresult FlushText();
     nsresult AddText(const char16_t* aText, int32_t aLength);
 
     // RDF-specific parsing
     nsresult OpenRDF(const char16_t* aName);
--- a/rdf/base/src/nsRDFService.cpp
+++ b/rdf/base/src/nsRDFService.cpp
@@ -278,27 +278,29 @@ public:
     {
         mData.mLength = aLength;
         mData.mBytes = new uint8_t[aLength];
         memcpy(mData.mBytes, aBytes, aLength);
         NS_ADDREF(RDFServiceImpl::gRDFService);
         RDFServiceImpl::gRDFService->RegisterBlob(this);
     }
 
+protected:
     virtual ~BlobImpl()
     {
         RDFServiceImpl::gRDFService->UnregisterBlob(this);
         // Use NS_RELEASE2() here, because we want to decrease the
         // refcount, but not null out the gRDFService pointer (which is
         // what a vanilla NS_RELEASE() would do).
         nsrefcnt refcnt;
         NS_RELEASE2(RDFServiceImpl::gRDFService, refcnt);
         delete[] mData.mBytes;
     }
 
+public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIRDFNODE
     NS_DECL_NSIRDFBLOB
 
     Data mData;
 };
 
 NS_IMPL_ISUPPORTS(BlobImpl, nsIRDFNode, nsIRDFBlob)
@@ -515,28 +517,29 @@ LiteralImpl::GetValueConst(const char16_
 
 ////////////////////////////////////////////////////////////////////////
 // DateImpl
 //
 
 class DateImpl : public nsIRDFDate {
 public:
     DateImpl(const PRTime s);
-    virtual ~DateImpl();
 
     // nsISupports
     NS_DECL_ISUPPORTS
 
     // nsIRDFNode
     NS_DECL_NSIRDFNODE
 
     // nsIRDFDate
     NS_IMETHOD GetValue(PRTime *value);
 
 private:
+    virtual ~DateImpl();
+
     nsresult EqualsDate(nsIRDFDate* date, bool* result);
     PRTime mValue;
 };
 
 
 DateImpl::DateImpl(const PRTime s)
     : mValue(s)
 {
@@ -621,28 +624,29 @@ DateImpl::EqualsDate(nsIRDFDate* date, b
 
 ////////////////////////////////////////////////////////////////////////
 // IntImpl
 //
 
 class IntImpl : public nsIRDFInt {
 public:
     IntImpl(int32_t s);
-    virtual ~IntImpl();
 
     // nsISupports
     NS_DECL_ISUPPORTS
 
     // nsIRDFNode
     NS_DECL_NSIRDFNODE
 
     // nsIRDFInt
     NS_IMETHOD GetValue(int32_t *value);
 
 private:
+    virtual ~IntImpl();
+
     nsresult EqualsInt(nsIRDFInt* value, bool* result);
     int32_t mValue;
 };
 
 
 IntImpl::IntImpl(int32_t s)
     : mValue(s)
 {
--- a/rdf/base/src/nsRDFXMLSerializer.cpp
+++ b/rdf/base/src/nsRDFXMLSerializer.cpp
@@ -1008,16 +1008,17 @@ nsRDFXMLSerializer::SerializeEpilogue(ns
 
 class QNameCollector MOZ_FINAL : public rdfITripleVisitor {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_RDFITRIPLEVISITOR
     QNameCollector(nsRDFXMLSerializer* aParent)
         : mParent(aParent){}
 private:
+    ~QNameCollector() {}
     nsRDFXMLSerializer* mParent;
 };
 
 NS_IMPL_ISUPPORTS(QNameCollector, rdfITripleVisitor)
 nsresult
 QNameCollector::Visit(nsIRDFNode* aSubject, nsIRDFResource* aPredicate,
                       nsIRDFNode* aObject, bool aTruthValue)
 {
--- a/rdf/base/src/rdfTriplesSerializer.cpp
+++ b/rdf/base/src/rdfTriplesSerializer.cpp
@@ -23,16 +23,17 @@
 
 class TriplesVisitor MOZ_FINAL : public rdfITripleVisitor
 {
 public:
     TriplesVisitor(nsIOutputStream* aOut) : mOut(aOut) {}
     NS_DECL_RDFITRIPLEVISITOR
     NS_DECL_ISUPPORTS
 protected:
+    ~TriplesVisitor() {}
     nsresult writeResource(nsIRDFResource* aResource);
     nsIOutputStream* mOut;
 };
 
 NS_IMPL_ISUPPORTS(TriplesVisitor, rdfITripleVisitor)
 
 nsresult
 TriplesVisitor::writeResource(nsIRDFResource *aResource)
--- a/rdf/datasource/src/nsFileSystemDataSource.h
+++ b/rdf/datasource/src/nsFileSystemDataSource.h
@@ -22,21 +22,21 @@ class FileSystemDataSource MOZ_FINAL : p
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIRDFDATASOURCE
 
     static nsresult Create(nsISupports* aOuter,
                            const nsIID& aIID, void **aResult);
 
-    ~FileSystemDataSource() { }
     nsresult Init();
 
 private:
     FileSystemDataSource() { }
+    ~FileSystemDataSource() { }
 
     // helper methods
     bool     isFileURI(nsIRDFResource* aResource);
     bool     isDirURI(nsIRDFResource* aSource);
     nsresult GetVolumeList(nsISimpleEnumerator **aResult);
     nsresult GetFolderList(nsIRDFResource *source, bool allowHidden, bool onlyFirst, nsISimpleEnumerator **aResult);
     nsresult GetName(nsIRDFResource *source, nsIRDFLiteral** aResult);
     nsresult GetURL(nsIRDFResource *source, bool *isFavorite, nsIRDFLiteral** aResult);
--- a/rdf/tests/rdfcat/rdfcat.cpp
+++ b/rdf/tests/rdfcat/rdfcat.cpp
@@ -51,19 +51,21 @@ static NS_DEFINE_CID(kRDFXMLDataSourceCI
         return 1;\
     } \
     PR_END_MACRO
 
 ////////////////////////////////////////////////////////////////////////
 
 class ConsoleOutputStreamImpl : public nsIOutputStream
 {
+protected:
+    virtual ~ConsoleOutputStreamImpl(void) {}
+
 public:
     ConsoleOutputStreamImpl(void) {}
-    virtual ~ConsoleOutputStreamImpl(void) {}
 
     // nsISupports interface
     NS_DECL_ISUPPORTS
 
     // nsIOutputStream interface
     NS_IMETHOD Close(void) {
         return NS_OK;
     }
--- a/rdf/tests/rdfpoll/rdfpoll.cpp
+++ b/rdf/tests/rdfpoll/rdfpoll.cpp
@@ -50,19 +50,21 @@ static NS_DEFINE_CID(kRDFXMLDataSourceCI
 
 
 #include "nsIMemory.h" // for the CID
 
 ////////////////////////////////////////////////////////////////////////
 
 class Observer : public nsIRDFObserver
 {
+protected:
+    virtual ~Observer() {}
+
 public:
     Observer();
-    virtual ~Observer() {}
 
     // nsISupports interface
     NS_DECL_ISUPPORTS
 
     // nsIRDFObserver interface
     NS_DECL_NSIRDFOBSERVER
 };
 
--- a/rdf/tests/triplescat/triplescat.cpp
+++ b/rdf/tests/triplescat/triplescat.cpp
@@ -49,19 +49,21 @@
         return 1;\
     } \
     PR_END_MACRO
 
 ////////////////////////////////////////////////////////////////////////
 
 class ConsoleOutputStreamImpl : public nsIOutputStream
 {
+protected:
+    virtual ~ConsoleOutputStreamImpl(void) {}
+
 public:
     ConsoleOutputStreamImpl(void) {}
-    virtual ~ConsoleOutputStreamImpl(void) {}
 
     // nsISupports interface
     NS_DECL_ISUPPORTS
 
     // nsIOutputStream interface
     NS_IMETHOD Close(void) {
         return NS_OK;
     }
--- a/rdf/util/public/nsRDFResource.h
+++ b/rdf/util/public/nsRDFResource.h
@@ -33,19 +33,19 @@ public:
     NS_IMETHOD GetValueUTF8(nsACString& aResult);
     NS_IMETHOD GetValueConst(const char** aURI);
     NS_IMETHOD EqualsString(const char* aURI, bool* aResult);
     NS_IMETHOD GetDelegate(const char* aKey, REFNSIID aIID, void** aResult);
     NS_IMETHOD ReleaseDelegate(const char* aKey);
 
     // nsRDFResource methods:
     nsRDFResource(void);
-    virtual ~nsRDFResource(void);
 
 protected:
+    virtual ~nsRDFResource(void);
     static nsIRDFService* gRDFService;
     static nsrefcnt gRDFServiceRefCnt;
 
 protected:
     nsCString mURI;
 
     struct DelegateEntry {
         nsCString             mKey;