Skip to content

Commit 210693d

Browse files
author
Benoit Jacob
committed
Bug 1028588 - Fix dangerous public destructors in toolkit/ - r=ehsan
1 parent f5daf8e commit 210693d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+165
-37
lines changed

toolkit/components/alerts/nsAlertsService.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
1+
// /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* This Source Code Form is subject to the terms of the Mozilla Public
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -36,9 +36,10 @@ class nsAlertsService : public nsIAlertsService,
3636
NS_DECL_ISUPPORTS
3737

3838
nsAlertsService();
39-
virtual ~nsAlertsService();
4039

4140
protected:
41+
virtual ~nsAlertsService();
42+
4243
bool ShouldShowAlert();
4344
nsXULAlerts mXULAlerts;
4445
};

toolkit/components/alerts/nsXULAlerts.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class nsXULAlertObserver : public nsIObserver {
4949

5050
void SetAlertWindow(nsIDOMWindow* aWindow) { mAlertWindow = aWindow; }
5151

52-
virtual ~nsXULAlertObserver() {}
5352
protected:
53+
virtual ~nsXULAlertObserver() {}
54+
5455
nsXULAlerts* mXULAlerts;
5556
nsString mAlertName;
5657
nsCOMPtr<nsIDOMWindow> mAlertWindow;

toolkit/components/autocomplete/nsAutoCompleteController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ class nsAutoCompleteController : public nsIAutoCompleteController,
3535
NS_DECL_NSITIMERCALLBACK
3636

3737
nsAutoCompleteController();
38-
virtual ~nsAutoCompleteController();
3938

4039
protected:
40+
virtual ~nsAutoCompleteController();
41+
4142
nsresult OpenPopup();
4243
nsresult ClosePopup();
4344

toolkit/components/downloads/ApplicationReputation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class PendingLookup MOZ_FINAL : public nsIStreamListener
8484
// Constructor and destructor.
8585
PendingLookup(nsIApplicationReputationQuery* aQuery,
8686
nsIApplicationReputationCallback* aCallback);
87-
~PendingLookup();
8887

8988
// Start the lookup. The lookup may have 2 parts: local and remote. In the
9089
// local lookup, PendingDBLookups are created to query the local allow and
@@ -94,6 +93,8 @@ class PendingLookup MOZ_FINAL : public nsIStreamListener
9493
nsresult StartLookup();
9594

9695
private:
96+
~PendingLookup();
97+
9798
friend class PendingDBLookup;
9899

99100
// Telemetry states.
@@ -210,13 +211,15 @@ class PendingDBLookup MOZ_FINAL : public nsIUrlClassifierCallback
210211

211212
// Constructor and destructor
212213
PendingDBLookup(PendingLookup* aPendingLookup);
213-
~PendingDBLookup();
214214

215215
// Look up the given URI in the safebrowsing DBs, optionally on both the allow
216216
// list and the blocklist. If there is a match, call
217217
// PendingLookup::OnComplete. Otherwise, call PendingLookup::LookupNext.
218218
nsresult LookupSpec(const nsACString& aSpec, bool aAllowlistOnly);
219+
219220
private:
221+
~PendingDBLookup();
222+
220223
// The download appeared on the allowlist, blocklist, or no list (and thus
221224
// could trigger a remote query.
222225
enum LIST_TYPES {

toolkit/components/downloads/SQLFunctions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace downloads {
2424
*/
2525
class GenerateGUIDFunction MOZ_FINAL : public mozIStorageFunction
2626
{
27+
~GenerateGUIDFunction() {}
2728
public:
2829
NS_DECL_THREADSAFE_ISUPPORTS
2930
NS_DECL_MOZISTORAGEFUNCTION

toolkit/components/downloads/nsDownloadManager.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class nsDownloadManager : public nsIDownloadManager,
5353

5454
static nsDownloadManager *GetSingleton();
5555

56-
virtual ~nsDownloadManager();
5756
nsDownloadManager()
5857
#ifdef DOWNLOAD_SCANNER
5958
: mScanner(nullptr)
@@ -62,6 +61,8 @@ class nsDownloadManager : public nsIDownloadManager,
6261
}
6362

6463
protected:
64+
virtual ~nsDownloadManager();
65+
6566
nsresult InitDB();
6667
nsresult InitFileDB();
6768
void CloseAllDBs();
@@ -273,7 +274,6 @@ class nsDownload : public nsIDownload
273274
NS_DECL_ISUPPORTS
274275

275276
nsDownload();
276-
virtual ~nsDownload();
277277

278278
/**
279279
* This method MUST be called when changing states on a download. It will
@@ -283,6 +283,8 @@ class nsDownload : public nsIDownload
283283
nsresult SetState(DownloadState aState);
284284

285285
protected:
286+
virtual ~nsDownload();
287+
286288
/**
287289
* Finish up the download by breaking reference cycles and clearing unneeded
288290
* data. Additionally, the download removes itself from the download

toolkit/components/downloads/nsDownloadProxy.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
// deriving from nsISupports will throw ambiguous base class errors.
2424
class nsDownloadProxy : public nsITransfer
2525
{
26+
protected:
27+
28+
virtual ~nsDownloadProxy() { }
29+
2630
public:
2731

2832
nsDownloadProxy() { }
29-
virtual ~nsDownloadProxy() { }
3033

3134
NS_DECL_ISUPPORTS
3235

toolkit/components/filepicker/nsFileView.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class nsFileResult MOZ_FINAL : public nsIAutoCompleteResult
4747
nsTArray<nsString> mValues;
4848
nsAutoString mSearchString;
4949
uint16_t mSearchResult;
50+
private:
51+
~nsFileResult() {}
5052
};
5153

5254
NS_IMPL_ISUPPORTS(nsFileResult, nsIAutoCompleteResult)
@@ -185,6 +187,7 @@ NS_IMETHODIMP nsFileResult::RemoveValueAt(int32_t rowIndex, bool removeFromDb)
185187

186188
class nsFileComplete MOZ_FINAL : public nsIAutoCompleteSearch
187189
{
190+
~nsFileComplete() {}
188191
public:
189192
NS_DECL_ISUPPORTS
190193
NS_DECL_NSIAUTOCOMPLETESEARCH

toolkit/components/finalizationwitness/FinalizationWitnessService.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class FinalizationWitnessService MOZ_FINAL : public nsIFinalizationWitnessServic
1818
NS_DECL_ISUPPORTS
1919
NS_DECL_NSIFINALIZATIONWITNESSSERVICE
2020
private:
21+
~FinalizationWitnessService() {}
2122
void operator=(const FinalizationWitnessService* other) MOZ_DELETE;
2223
};
2324

toolkit/components/find/nsFindService.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ class nsFindService : public nsIFindService
2727
{
2828
public:
2929

30-
nsFindService();
31-
virtual ~nsFindService();
30+
nsFindService();
3231

3332
NS_DECL_ISUPPORTS
3433
NS_DECL_NSIFINDSERVICE
3534

3635
protected:
3736

37+
virtual ~nsFindService();
38+
3839
nsString mSearchString;
3940
nsString mReplaceString;
4041

0 commit comments

Comments
 (0)