From 35b82308d83de6aaeed64c918701d13bb33f6571 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 30 Jun 2014 18:11:53 -0400 Subject: [PATCH] Bug 1028588 - Fix dangerous public destructors in xpcom/ - r=bsmedberg,khuey,nfroyd --- xpcom/base/AvailableMemoryTracker.cpp | 4 ++++ xpcom/base/SystemMemoryReporter.cpp | 2 ++ xpcom/base/nsCycleCollector.cpp | 28 ++++++++++++---------- xpcom/base/nsDumpUtils.h | 12 +++++----- xpcom/base/nsGZFileWriter.h | 3 ++- xpcom/base/nsIStatusReporter.idl | 1 + xpcom/base/nsInterfaceRequestorAgg.cpp | 3 ++- xpcom/base/nsMemoryInfoDumper.cpp | 6 +++++ xpcom/base/nsMemoryInfoDumper.h | 4 ++-- xpcom/base/nsMemoryReporterManager.cpp | 18 ++++++++++++++ xpcom/base/nsMemoryReporterManager.h | 3 ++- xpcom/base/nsMessageLoop.cpp | 8 +++---- xpcom/base/nsMessageLoop.h | 1 + xpcom/base/nsStatusReporterManager.h | 9 +++---- xpcom/base/nsVersionComparatorImpl.h | 2 ++ xpcom/build/nsXPComInit.cpp | 8 +++++++ xpcom/components/ModuleUtils.h | 2 ++ xpcom/components/nsNativeComponentLoader.h | 10 ++++++++ xpcom/ds/nsArray.h | 4 ++++ xpcom/ds/nsHashPropertyBag.cpp | 5 +++- xpcom/ds/nsHashPropertyBag.h | 3 ++- xpcom/ds/nsINIParserImpl.cpp | 2 ++ xpcom/ds/nsINIParserImpl.h | 2 ++ xpcom/ds/nsSupportsArray.h | 7 +++--- xpcom/glue/GenericFactory.h | 2 ++ xpcom/glue/nsCategoryCache.h | 3 ++- xpcom/glue/nsThreadUtils.cpp | 2 ++ xpcom/io/nsAppFileLocationProvider.cpp | 18 +++++++------- xpcom/io/nsBinaryStream.h | 20 +++++++++------- xpcom/io/nsDirectoryService.h | 3 ++- xpcom/io/nsIOUtil.h | 2 ++ xpcom/io/nsStreamUtils.cpp | 10 ++++---- xpcom/reflect/xptinfo/ShimInterfaceInfo.h | 2 ++ xpcom/tests/TestCOMArray.cpp | 6 +++-- xpcom/tests/TestCallTemplates.cpp | 1 + xpcom/tests/TestRacingServiceManager.cpp | 6 +++++ xpcom/tests/TestThreadPoolListener.cpp | 2 ++ xpcom/tests/TestThreadUtils.cpp | 11 ++++++++- xpcom/tests/TestTimers.cpp | 2 ++ 39 files changed, 174 insertions(+), 63 deletions(-) diff --git a/xpcom/base/AvailableMemoryTracker.cpp b/xpcom/base/AvailableMemoryTracker.cpp index eae94f0e83d..4cbbdd683a5 100644 --- a/xpcom/base/AvailableMemoryTracker.cpp +++ b/xpcom/base/AvailableMemoryTracker.cpp @@ -396,6 +396,8 @@ NS_IMPL_ISUPPORTS(LowEventsReporter, nsIMemoryReporter) */ class nsJemallocFreeDirtyPagesRunnable MOZ_FINAL : public nsIRunnable { + ~nsJemallocFreeDirtyPagesRunnable() {} + public: NS_DECL_ISUPPORTS NS_DECL_NSIRUNNABLE @@ -422,6 +424,8 @@ nsJemallocFreeDirtyPagesRunnable::Run() */ class nsMemoryPressureWatcher MOZ_FINAL : public nsIObserver { + ~nsMemoryPressureWatcher() {} + public: NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER diff --git a/xpcom/base/SystemMemoryReporter.cpp b/xpcom/base/SystemMemoryReporter.cpp index 9d0438d352f..2dd32cc87d9 100644 --- a/xpcom/base/SystemMemoryReporter.cpp +++ b/xpcom/base/SystemMemoryReporter.cpp @@ -114,6 +114,8 @@ IsAnonymous(const nsACString& aName) class SystemReporter MOZ_FINAL : public nsIMemoryReporter { + ~SystemReporter() {} + public: NS_DECL_THREADSAFE_ISUPPORTS diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index e289508bb2f..89d8dfc913c 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -1273,9 +1273,11 @@ class nsCycleCollector : public nsIMemoryReporter JSPurpleBuffer* mJSPurpleBuffer; +private: + virtual ~nsCycleCollector(); + public: nsCycleCollector(); - virtual ~nsCycleCollector(); void RegisterJSRuntime(CycleCollectedJSRuntime* aJSRuntime); void ForgetJSRuntime(); @@ -1705,6 +1707,11 @@ NS_IMPL_ISUPPORTS(nsCycleCollectorLogSinkToFile, nsICycleCollectorLogSink) class nsCycleCollectorLogger MOZ_FINAL : public nsICycleCollectorListener { + ~nsCycleCollectorLogger() + { + ClearDescribers(); + } + public: nsCycleCollectorLogger() : mLogSink(nsCycleCollector_createLogSink()) @@ -1715,11 +1722,6 @@ public: { } - ~nsCycleCollectorLogger() - { - ClearDescribers(); - } - NS_DECL_ISUPPORTS void SetAllTraces() @@ -2509,6 +2511,13 @@ private: // removed. class JSPurpleBuffer { + ~JSPurpleBuffer() + { + MOZ_ASSERT(mValues.IsEmpty()); + MOZ_ASSERT(mObjects.IsEmpty()); + MOZ_ASSERT(mTenuredObjects.IsEmpty()); + } + public: JSPurpleBuffer(JSPurpleBuffer*& aReferenceToThis) : mReferenceToThis(aReferenceToThis) @@ -2518,13 +2527,6 @@ public: mozilla::HoldJSObjects(this); } - ~JSPurpleBuffer() - { - MOZ_ASSERT(mValues.IsEmpty()); - MOZ_ASSERT(mObjects.IsEmpty()); - MOZ_ASSERT(mTenuredObjects.IsEmpty()); - } - void Destroy() { mReferenceToThis = nullptr; diff --git a/xpcom/base/nsDumpUtils.h b/xpcom/base/nsDumpUtils.h index 443f41fd7c3..b164d0f95bb 100644 --- a/xpcom/base/nsDumpUtils.h +++ b/xpcom/base/nsDumpUtils.h @@ -40,6 +40,12 @@ protected: MessageLoopForIO::FileDescriptorWatcher mReadWatcher; int mFd; + virtual ~FdWatcher() + { + // StopWatching should have run. + MOZ_ASSERT(mFd == -1); + } + public: FdWatcher() : mFd(-1) @@ -47,12 +53,6 @@ public: MOZ_ASSERT(NS_IsMainThread()); } - virtual ~FdWatcher() - { - // StopWatching should have run. - MOZ_ASSERT(mFd == -1); - } - /** * Open the fd to watch. If we encounter an error, return -1. */ diff --git a/xpcom/base/nsGZFileWriter.h b/xpcom/base/nsGZFileWriter.h index faacf099b00..088671c0a1d 100644 --- a/xpcom/base/nsGZFileWriter.h +++ b/xpcom/base/nsGZFileWriter.h @@ -15,9 +15,10 @@ */ class nsGZFileWriter : public nsIGZFileWriter { + virtual ~nsGZFileWriter(); + public: nsGZFileWriter(); - virtual ~nsGZFileWriter(); NS_DECL_ISUPPORTS NS_DECL_NSIGZFILEWRITER diff --git a/xpcom/base/nsIStatusReporter.idl b/xpcom/base/nsIStatusReporter.idl index d1045fda4b9..605151b15ee 100644 --- a/xpcom/base/nsIStatusReporter.idl +++ b/xpcom/base/nsIStatusReporter.idl @@ -66,6 +66,7 @@ interface nsIStatusReporterManager : nsISupports */ #define NS_STATUS_REPORTER_IMPLEMENT(_classname, _name, _desc_Function) \ class StatusReporter_##_classname MOZ_FINAL : public nsIStatusReporter { \ + ~StatusReporter_##_classname() {} \ public: \ NS_DECL_ISUPPORTS \ NS_IMETHOD GetName(nsACString &name) \ diff --git a/xpcom/base/nsInterfaceRequestorAgg.cpp b/xpcom/base/nsInterfaceRequestorAgg.cpp index 178b7b3890b..6e777f5613c 100644 --- a/xpcom/base/nsInterfaceRequestorAgg.cpp +++ b/xpcom/base/nsInterfaceRequestorAgg.cpp @@ -29,9 +29,10 @@ public: mConsumerTarget = NS_GetCurrentThread(); } } - ~nsInterfaceRequestorAgg(); private: + ~nsInterfaceRequestorAgg(); + nsCOMPtr mFirst, mSecond; nsCOMPtr mConsumerTarget; }; diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index d9dc8cf9570..0491e50a413 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -496,6 +496,8 @@ public: } private: + ~DumpReportCallback() {} + bool mIsFirst; nsRefPtr mWriter; }; @@ -588,6 +590,8 @@ public: NS_IMETHOD Callback(nsISupports* aData); private: + ~TempDirMemoryFinishCallback() {} + nsRefPtr mrWriter; nsCOMPtr mrTmpFile; nsCString mrFilename; @@ -823,6 +827,8 @@ public: } private: + ~FinishReportingCallback() {} + nsCOMPtr mFinishDumping; nsCOMPtr mFinishDumpingData; }; diff --git a/xpcom/base/nsMemoryInfoDumper.h b/xpcom/base/nsMemoryInfoDumper.h index 5baa3ef2451..ad6b0394ff9 100644 --- a/xpcom/base/nsMemoryInfoDumper.h +++ b/xpcom/base/nsMemoryInfoDumper.h @@ -20,14 +20,14 @@ class nsACString; */ class nsMemoryInfoDumper : public nsIMemoryInfoDumper { + virtual ~nsMemoryInfoDumper(); + public: NS_DECL_ISUPPORTS NS_DECL_NSIMEMORYINFODUMPER nsMemoryInfoDumper(); - virtual ~nsMemoryInfoDumper(); -public: static void Initialize(); #ifdef MOZ_DMD diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 197f4e053ca..63cd7da1fb7 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -118,6 +118,8 @@ ResidentUniqueDistinguishedAmount(int64_t* aN) class ResidentUniqueReporter MOZ_FINAL : public nsIMemoryReporter { + ~ResidentUniqueReporter() {} + public: NS_DECL_ISUPPORTS @@ -558,6 +560,8 @@ NS_IMPL_ISUPPORTS(PrivateReporter, nsIMemoryReporter) #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS class VsizeReporter MOZ_FINAL : public nsIMemoryReporter { + ~VsizeReporter() {} + public: NS_DECL_ISUPPORTS @@ -583,6 +587,8 @@ NS_IMPL_ISUPPORTS(VsizeReporter, nsIMemoryReporter) class ResidentReporter MOZ_FINAL : public nsIMemoryReporter { + ~ResidentReporter() {} + public: NS_DECL_ISUPPORTS @@ -615,6 +621,8 @@ NS_IMPL_ISUPPORTS(ResidentReporter, nsIMemoryReporter) class PageFaultsSoftReporter MOZ_FINAL : public nsIMemoryReporter { + ~PageFaultsSoftReporter() {} + public: NS_DECL_ISUPPORTS @@ -657,6 +665,8 @@ PageFaultsHardDistinguishedAmount(int64_t* aAmount) class PageFaultsHardReporter MOZ_FINAL : public nsIMemoryReporter { + ~PageFaultsHardReporter() {} + public: NS_DECL_ISUPPORTS @@ -704,6 +714,8 @@ HeapOverheadRatio(jemalloc_stats_t* aStats) class JemallocHeapReporter MOZ_FINAL : public nsIMemoryReporter { + ~JemallocHeapReporter() {} + public: NS_DECL_ISUPPORTS @@ -808,6 +820,8 @@ class AtomTablesReporter MOZ_FINAL : public nsIMemoryReporter { MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) + ~AtomTablesReporter() {} + public: NS_DECL_ISUPPORTS @@ -1443,6 +1457,8 @@ nsMemoryReporterManager::UnblockRegistrationAndRestoreOriginalReporters() // passed to nsIMemoryReporter::CollectReports. class Int64Wrapper MOZ_FINAL : public nsISupports { + ~Int64Wrapper() {} + public: NS_DECL_ISUPPORTS Int64Wrapper() : mValue(0) @@ -1455,6 +1471,8 @@ NS_IMPL_ISUPPORTS0(Int64Wrapper) class ExplicitCallback MOZ_FINAL : public nsIHandleReportCallback { + ~ExplicitCallback() {} + public: NS_DECL_ISUPPORTS diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h index cd90da39c17..c8afcb49b0c 100644 --- a/xpcom/base/nsMemoryReporterManager.h +++ b/xpcom/base/nsMemoryReporterManager.h @@ -24,12 +24,13 @@ class MemoryReport; class nsMemoryReporterManager : public nsIMemoryReporterManager { + virtual ~nsMemoryReporterManager(); + public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIMEMORYREPORTERMANAGER nsMemoryReporterManager(); - virtual ~nsMemoryReporterManager(); // Gets the memory reporter manager service. static nsMemoryReporterManager* GetOrCreate() diff --git a/xpcom/base/nsMessageLoop.cpp b/xpcom/base/nsMessageLoop.cpp index e6335f22525..c7e9773489a 100644 --- a/xpcom/base/nsMessageLoop.cpp +++ b/xpcom/base/nsMessageLoop.cpp @@ -34,9 +34,6 @@ class MessageLoopIdleTask public: MOZ_DECLARE_REFCOUNTED_TYPENAME(MessageLoopIdleTask) MessageLoopIdleTask(nsIRunnable* aTask, uint32_t aEnsureRunsAfterMS); - virtual ~MessageLoopIdleTask() - { - } virtual void Run(); private: @@ -44,6 +41,8 @@ private: nsCOMPtr mTask; nsCOMPtr mTimer; + + virtual ~MessageLoopIdleTask() {} }; /** @@ -61,13 +60,14 @@ class MessageLoopTimerCallback { public: MessageLoopTimerCallback(MessageLoopIdleTask* aTask); - virtual ~MessageLoopTimerCallback() {}; NS_DECL_ISUPPORTS NS_DECL_NSITIMERCALLBACK private: WeakPtr mTask; + + virtual ~MessageLoopTimerCallback() {} }; MessageLoopIdleTask::MessageLoopIdleTask(nsIRunnable* aTask, diff --git a/xpcom/base/nsMessageLoop.h b/xpcom/base/nsMessageLoop.h index 96f853c83c0..e7b14622169 100644 --- a/xpcom/base/nsMessageLoop.h +++ b/xpcom/base/nsMessageLoop.h @@ -15,6 +15,7 @@ class nsMessageLoop : public nsIMessageLoop NS_DECL_ISUPPORTS NS_DECL_NSIMESSAGELOOP +private: virtual ~nsMessageLoop() { } diff --git a/xpcom/base/nsStatusReporterManager.h b/xpcom/base/nsStatusReporterManager.h index 0c06ba776ac..d74ac2816d9 100644 --- a/xpcom/base/nsStatusReporterManager.h +++ b/xpcom/base/nsStatusReporterManager.h @@ -17,12 +17,12 @@ public: nsStatusReporter(nsACString& aProcess, nsACString& aDesc); - virtual ~nsStatusReporter(); - -protected: +private: nsCString sProcess; nsCString sName; nsCString sDesc; + + virtual ~nsStatusReporter(); }; @@ -33,8 +33,9 @@ public: NS_DECL_NSISTATUSREPORTERMANAGER nsStatusReporterManager(); - virtual ~nsStatusReporterManager(); private: nsCOMArray mReporters; + + virtual ~nsStatusReporterManager(); }; diff --git a/xpcom/base/nsVersionComparatorImpl.h b/xpcom/base/nsVersionComparatorImpl.h index 2c9f927fdde..44e80eb2e8e 100644 --- a/xpcom/base/nsVersionComparatorImpl.h +++ b/xpcom/base/nsVersionComparatorImpl.h @@ -10,6 +10,8 @@ class nsVersionComparatorImpl MOZ_FINAL : public nsIVersionComparator { + ~nsVersionComparatorImpl() {} + public: NS_DECL_ISUPPORTS NS_DECL_NSIVERSIONCOMPARATOR diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index 5b4deb8a6bc..efab931019f 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -380,6 +380,8 @@ private: "explicit/icu", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory used by ICU, a Unicode and globalization support library."); } + + ~ICUReporter() {} }; NS_IMPL_ISUPPORTS(ICUReporter, nsIMemoryReporter) @@ -401,6 +403,8 @@ private: "explicit/media/libogg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory allocated through libogg for Ogg, Theora, and related media files."); } + + ~OggReporter() {} }; NS_IMPL_ISUPPORTS(OggReporter, nsIMemoryReporter) @@ -423,6 +427,8 @@ private: "explicit/media/libvpx", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory allocated through libvpx for WebM media files."); } + + ~VPXReporter() {} }; NS_IMPL_ISUPPORTS(VPXReporter, nsIMemoryReporter) @@ -446,6 +452,8 @@ private: "explicit/media/libnestegg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory allocated through libnestegg for WebM media files."); } + + ~NesteggReporter() {} }; NS_IMPL_ISUPPORTS(NesteggReporter, nsIMemoryReporter) diff --git a/xpcom/components/ModuleUtils.h b/xpcom/components/ModuleUtils.h index 93290ddcdde..ba22287b45f 100644 --- a/xpcom/components/ModuleUtils.h +++ b/xpcom/components/ModuleUtils.h @@ -104,6 +104,8 @@ namespace mozilla { class GenericModule MOZ_FINAL : public nsIModule { + ~GenericModule() {} + public: GenericModule(const mozilla::Module* aData) : mData(aData) diff --git a/xpcom/components/nsNativeComponentLoader.h b/xpcom/components/nsNativeComponentLoader.h index a76a6251ae1..e006d516491 100644 --- a/xpcom/components/nsNativeComponentLoader.h +++ b/xpcom/components/nsNativeComponentLoader.h @@ -13,6 +13,16 @@ #include "mozilla/Module.h" #include "prlink.h" +class nsNativeModuleLoader; + +namespace mozilla { +template<> +struct HasDangerousPublicDestructor +{ + static const bool value = true; +}; +} + class nsNativeModuleLoader : public mozilla::ModuleLoader { public: diff --git a/xpcom/ds/nsArray.h b/xpcom/ds/nsArray.h index b32876320b8..34832d5a51a 100644 --- a/xpcom/ds/nsArray.h +++ b/xpcom/ds/nsArray.h @@ -64,6 +64,8 @@ private: : nsArrayBase(aBaseArray) { } + + ~nsArray() {} }; class nsArrayCC MOZ_FINAL : public nsArrayBase @@ -84,6 +86,8 @@ private: : nsArrayBase(aBaseArray) { } + + ~nsArrayCC() {} }; #endif diff --git a/xpcom/ds/nsHashPropertyBag.cpp b/xpcom/ds/nsHashPropertyBag.cpp index e95c4d3ab6c..8aaa738e485 100644 --- a/xpcom/ds/nsHashPropertyBag.cpp +++ b/xpcom/ds/nsHashPropertyBag.cpp @@ -93,7 +93,10 @@ nsHashPropertyBag::DeleteProperty(const nsAString& name) // nsSimpleProperty class and impl; used for GetEnumerator // -class nsSimpleProperty MOZ_FINAL : public nsIProperty { +class nsSimpleProperty MOZ_FINAL : public nsIProperty +{ + ~nsSimpleProperty() {} + public: nsSimpleProperty(const nsAString& aName, nsIVariant* aValue) : mName(aName), mValue(aValue) diff --git a/xpcom/ds/nsHashPropertyBag.h b/xpcom/ds/nsHashPropertyBag.h index 53c1ba51337..f790796a96c 100644 --- a/xpcom/ds/nsHashPropertyBag.h +++ b/xpcom/ds/nsHashPropertyBag.h @@ -16,7 +16,6 @@ class nsHashPropertyBag : public nsIWritablePropertyBag { public: nsHashPropertyBag() { } - virtual ~nsHashPropertyBag() {} NS_DECL_THREADSAFE_ISUPPORTS @@ -31,6 +30,8 @@ public: protected: // a hash table of string -> nsIVariant nsInterfaceHashtable mPropertyHash; + + virtual ~nsHashPropertyBag() {} }; // Note: NS_NewHashPropertyBag returns a HPB that diff --git a/xpcom/ds/nsINIParserImpl.cpp b/xpcom/ds/nsINIParserImpl.cpp index ab060caa6c0..460681057a2 100644 --- a/xpcom/ds/nsINIParserImpl.cpp +++ b/xpcom/ds/nsINIParserImpl.cpp @@ -12,6 +12,8 @@ class nsINIParserImpl MOZ_FINAL : public nsIINIParser { + ~nsINIParserImpl() {} + public: NS_DECL_ISUPPORTS NS_DECL_NSIINIPARSER diff --git a/xpcom/ds/nsINIParserImpl.h b/xpcom/ds/nsINIParserImpl.h index e480d476fc0..803e005f0d7 100644 --- a/xpcom/ds/nsINIParserImpl.h +++ b/xpcom/ds/nsINIParserImpl.h @@ -20,6 +20,8 @@ class nsINIParserFactory MOZ_FINAL : public nsIINIParserFactory, public nsIFactory { + ~nsINIParserFactory() {} + public: NS_DECL_ISUPPORTS NS_DECL_NSIINIPARSERFACTORY diff --git a/xpcom/ds/nsSupportsArray.h b/xpcom/ds/nsSupportsArray.h index 6346513604b..a2afd56a7d2 100644 --- a/xpcom/ds/nsSupportsArray.h +++ b/xpcom/ds/nsSupportsArray.h @@ -13,11 +13,12 @@ static const uint32_t kAutoArraySize = 8; -class nsSupportsArray MOZ_FINAL : public nsISupportsArray { -public: - nsSupportsArray(void); +class nsSupportsArray MOZ_FINAL : public nsISupportsArray +{ ~nsSupportsArray(void); // nonvirtual since we're not subclassed +public: + nsSupportsArray(void); static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); diff --git a/xpcom/glue/GenericFactory.h b/xpcom/glue/GenericFactory.h index acadf817bb2..b08dd0ad6fc 100644 --- a/xpcom/glue/GenericFactory.h +++ b/xpcom/glue/GenericFactory.h @@ -20,6 +20,8 @@ namespace mozilla { */ class GenericFactory MOZ_FINAL : public nsIFactory { + ~GenericFactory() {} + public: typedef Module::ConstructorProcPtr ConstructorProcPtr; diff --git a/xpcom/glue/nsCategoryCache.h b/xpcom/glue/nsCategoryCache.h index 76e9644ec94..93a8ef306e4 100644 --- a/xpcom/glue/nsCategoryCache.h +++ b/xpcom/glue/nsCategoryCache.h @@ -24,9 +24,10 @@ class NS_COM_GLUE nsCategoryObserver MOZ_FINAL : public nsIObserver { + ~nsCategoryObserver(); + public: nsCategoryObserver(const char* aCategory); - ~nsCategoryObserver(); void ListenerDied(); nsInterfaceHashtable& GetHash() diff --git a/xpcom/glue/nsThreadUtils.cpp b/xpcom/glue/nsThreadUtils.cpp index 070bdcc1f0d..6a97463392a 100644 --- a/xpcom/glue/nsThreadUtils.cpp +++ b/xpcom/glue/nsThreadUtils.cpp @@ -290,6 +290,8 @@ namespace { class nsNameThreadRunnable MOZ_FINAL : public nsIRunnable { + ~nsNameThreadRunnable() {} + public: nsNameThreadRunnable(const nsACString& aName) : mName(aName) {} diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index d6a6449965f..4048ff29461 100644 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -451,17 +451,16 @@ public: return *aResult ? NS_OK : NS_ERROR_FAILURE; } - // Virtual destructor since subclass nsPathsDirectoryEnumerator - // does not re-implement Release() - - virtual ~nsAppDirectoryEnumerator() - { - } - protected: nsIDirectoryServiceProvider* mProvider; const char** mCurrentKey; nsCOMPtr mNext; + + // Virtual destructor since subclass nsPathsDirectoryEnumerator + // does not re-implement Release() + virtual ~nsAppDirectoryEnumerator() + { + } }; NS_IMPL_ISUPPORTS(nsAppDirectoryEnumerator, nsISimpleEnumerator) @@ -475,8 +474,11 @@ NS_IMPL_ISUPPORTS(nsAppDirectoryEnumerator, nsISimpleEnumerator) #define PATH_SEPARATOR ':' #endif -class nsPathsDirectoryEnumerator : public nsAppDirectoryEnumerator +class nsPathsDirectoryEnumerator MOZ_FINAL + : public nsAppDirectoryEnumerator { + ~nsPathsDirectoryEnumerator() {} + public: /** * aKeyList is a null-terminated list. diff --git a/xpcom/io/nsBinaryStream.h b/xpcom/io/nsBinaryStream.h index 9e42305bf95..3fc22e172a4 100644 --- a/xpcom/io/nsBinaryStream.h +++ b/xpcom/io/nsBinaryStream.h @@ -31,10 +31,6 @@ public: nsBinaryOutputStream() { } - // virtual dtor since subclasses call our Release() - virtual ~nsBinaryOutputStream() - { - } protected: // nsISupports methods @@ -54,6 +50,12 @@ protected: nsCOMPtr mOutputStream; nsCOMPtr mBufferAccess; + +private: + // virtual dtor since subclasses call our Release() + virtual ~nsBinaryOutputStream() + { + } }; #define NS_BINARYINPUTSTREAM_CID \ @@ -74,10 +76,6 @@ public: nsBinaryInputStream() { } - // virtual dtor since subclasses call our Release() - virtual ~nsBinaryInputStream() - { - } protected: // nsISupports methods @@ -94,6 +92,12 @@ protected: nsCOMPtr mInputStream; nsCOMPtr mBufferAccess; + +private: + // virtual dtor since subclasses call our Release() + virtual ~nsBinaryInputStream() + { + } }; #endif // nsBinaryStream_h___ diff --git a/xpcom/io/nsDirectoryService.h b/xpcom/io/nsDirectoryService.h index e1b90a46249..ebd3e548f90 100644 --- a/xpcom/io/nsDirectoryService.h +++ b/xpcom/io/nsDirectoryService.h @@ -37,7 +37,6 @@ public: NS_DECL_NSIDIRECTORYSERVICEPROVIDER2 nsDirectoryService(); - ~nsDirectoryService(); static void RealInit(); void RegisterCategoryProviders(); @@ -48,6 +47,8 @@ public: static nsDirectoryService* gService; private: + ~nsDirectoryService(); + nsresult GetCurrentProcessDirectory(nsIFile** aFile); nsInterfaceHashtable mHashtable; diff --git a/xpcom/io/nsIOUtil.h b/xpcom/io/nsIOUtil.h index cf6ebab896e..63a10ffb922 100644 --- a/xpcom/io/nsIOUtil.h +++ b/xpcom/io/nsIOUtil.h @@ -17,6 +17,8 @@ class nsIOUtil MOZ_FINAL : public nsIIOUtil { + ~nsIOUtil() {} + public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIIOUTIL diff --git a/xpcom/io/nsStreamUtils.cpp b/xpcom/io/nsStreamUtils.cpp index aa4f8aa4a41..19598dcf663 100644 --- a/xpcom/io/nsStreamUtils.cpp +++ b/xpcom/io/nsStreamUtils.cpp @@ -233,11 +233,6 @@ public: { } - // virtual since subclasses call superclass Release() - virtual ~nsAStreamCopier() - { - } - // kick off the async copy... nsresult Start(nsIInputStream* aSource, nsIOutputStream* aSink, @@ -475,6 +470,11 @@ protected: bool mCloseSink; bool mCanceled; nsresult mCancelStatus; + + // virtual since subclasses call superclass Release() + virtual ~nsAStreamCopier() + { + } }; NS_IMPL_ISUPPORTS(nsAStreamCopier, diff --git a/xpcom/reflect/xptinfo/ShimInterfaceInfo.h b/xpcom/reflect/xptinfo/ShimInterfaceInfo.h index 67d6d898cc6..0599403177c 100644 --- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.h +++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.h @@ -40,6 +40,8 @@ private: const char* aName, const mozilla::dom::NativePropertyHooks* aNativePropHooks); + ~ShimInterfaceInfo() {} + private: nsIID mIID; nsAutoCString mName; diff --git a/xpcom/tests/TestCOMArray.cpp b/xpcom/tests/TestCOMArray.cpp index 358b26987a1..545990650f7 100644 --- a/xpcom/tests/TestCOMArray.cpp +++ b/xpcom/tests/TestCOMArray.cpp @@ -25,10 +25,11 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(IFoo, NS_IFOO_IID) class Foo MOZ_FINAL : public IFoo { + ~Foo(); + public: Foo(int32_t aID); - ~Foo(); // nsISupports implementation NS_DECL_ISUPPORTS @@ -78,7 +79,6 @@ class Bar MOZ_FINAL : public IBar { public: explicit Bar(nsCOMArray& aArray); - ~Bar(); // nsISupports implementation NS_DECL_ISUPPORTS @@ -86,6 +86,8 @@ public: static int32_t sReleaseCalled; private: + ~Bar(); + nsCOMArray& mArray; }; diff --git a/xpcom/tests/TestCallTemplates.cpp b/xpcom/tests/TestCallTemplates.cpp index 78996bce8fa..8537b4755f8 100644 --- a/xpcom/tests/TestCallTemplates.cpp +++ b/xpcom/tests/TestCallTemplates.cpp @@ -36,6 +36,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsITestService, NS_ITESTSERVICE_IID) class nsTestService MOZ_FINAL : public nsITestService, public nsSupportsWeakReference { + ~nsTestService() {} public: NS_DECL_ISUPPORTS }; diff --git a/xpcom/tests/TestRacingServiceManager.cpp b/xpcom/tests/TestRacingServiceManager.cpp index 609322b8d41..1852cf34d83 100644 --- a/xpcom/tests/TestRacingServiceManager.cpp +++ b/xpcom/tests/TestRacingServiceManager.cpp @@ -87,6 +87,8 @@ private: class Factory MOZ_FINAL : public nsIFactory { + ~Factory() {} + public: NS_DECL_THREADSAFE_ISUPPORTS @@ -107,6 +109,8 @@ NS_IMPL_ISUPPORTS(Factory, nsIFactory) class Component1 MOZ_FINAL : public nsISupports { + ~Component1() {} + public: NS_DECL_THREADSAFE_ISUPPORTS @@ -126,6 +130,8 @@ NS_INTERFACE_MAP_END class Component2 MOZ_FINAL : public nsISupports { + ~Component2() {} + public: NS_DECL_THREADSAFE_ISUPPORTS diff --git a/xpcom/tests/TestThreadPoolListener.cpp b/xpcom/tests/TestThreadPoolListener.cpp index 3c45eb38d30..05a91293c0a 100644 --- a/xpcom/tests/TestThreadPoolListener.cpp +++ b/xpcom/tests/TestThreadPoolListener.cpp @@ -47,6 +47,8 @@ static bool gAllThreadsShutDown = false; class Listener MOZ_FINAL : public nsIThreadPoolListener { + ~Listener() {} + public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSITHREADPOOLLISTENER diff --git a/xpcom/tests/TestThreadUtils.cpp b/xpcom/tests/TestThreadUtils.cpp index 9878b7578c1..98ad43ebcef 100644 --- a/xpcom/tests/TestThreadUtils.cpp +++ b/xpcom/tests/TestThreadUtils.cpp @@ -34,6 +34,14 @@ class nsFoo : public nsISupports { virtual ~nsFoo() {} }; +namespace mozilla { +template<> +struct HasDangerousPublicDestructor +{ + static const bool value = true; +}; +} + NS_IMPL_ISUPPORTS0(nsFoo) class TestSuicide : public nsRunnable { @@ -55,8 +63,9 @@ private: }; class nsBar : public nsISupports { - NS_DECL_ISUPPORTS virtual ~nsBar() {} +public: + NS_DECL_ISUPPORTS void DoBar1(void) { gRunnableExecuted[TEST_CALL_VOID_ARG_VOID_RETURN] = true; } diff --git a/xpcom/tests/TestTimers.cpp b/xpcom/tests/TestTimers.cpp index 6e397beb389..5bd64bfc7cc 100644 --- a/xpcom/tests/TestTimers.cpp +++ b/xpcom/tests/TestTimers.cpp @@ -92,6 +92,8 @@ public: return NS_OK; } private: + ~TimerCallback() {} + nsIThread** mThreadPtr; ReentrantMonitor* mReentrantMonitor; };