Skip to content

Commit ff32bb1

Browse files
author
Benoit Jacob
committed
Bug 1028588 - Fix dangerous public destructors in netwerk/ - r=mcmanus
1 parent 60fe48d commit ff32bb1

File tree

158 files changed

+458
-212
lines changed

Some content is hidden

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

158 files changed

+458
-212
lines changed

netwerk/base/src/ArrayBufferInputStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
class ArrayBufferInputStream : public nsIArrayBufferInputStream {
2323
public:
2424
ArrayBufferInputStream();
25-
virtual ~ArrayBufferInputStream() {}
2625
NS_DECL_ISUPPORTS
2726
NS_DECL_NSIARRAYBUFFERINPUTSTREAM
2827
NS_DECL_NSIINPUTSTREAM
2928

3029
private:
30+
virtual ~ArrayBufferInputStream() {}
3131
mozilla::Maybe<JS::PersistentRooted<JS::Value> > mArrayBuffer;
3232
uint8_t* mBuffer; // start of actual buffer
3333
uint32_t mBufferLength; // length of slice

netwerk/base/src/BackgroundFileSaver.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,13 @@ class DigestOutputStream : public nsNSSShutDownObject,
398398
NS_DECL_NSIOUTPUTSTREAM
399399
// Constructor. Neither parameter may be null. The caller owns both.
400400
DigestOutputStream(nsIOutputStream* outputStream, PK11Context* aContext);
401-
~DigestOutputStream();
402401

403402
// We don't own any NSS objects here, so no need to clean up
404403
void virtualDestroyNSSReference() { }
405404

406405
private:
406+
~DigestOutputStream();
407+
407408
// Calls to write are passed to this stream.
408409
nsCOMPtr<nsIOutputStream> mOutputStream;
409410
// Digest context used to compute the hash, owned by the caller.

netwerk/base/src/Dashboard.cpp

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ class SocketData
3939
mThread = nullptr;
4040
}
4141

42-
virtual ~SocketData()
43-
{
44-
}
45-
4642
uint64_t mTotalSent;
4743
uint64_t mTotalRecv;
4844
nsTArray<SocketInfo> mData;
4945
nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
5046
nsIThread *mThread;
47+
48+
private:
49+
virtual ~SocketData()
50+
{
51+
}
5152
};
5253

5354
NS_IMPL_ISUPPORTS0(SocketData)
@@ -56,6 +57,10 @@ NS_IMPL_ISUPPORTS0(SocketData)
5657
class HttpData
5758
: public nsISupports
5859
{
60+
virtual ~HttpData()
61+
{
62+
}
63+
5964
public:
6065
NS_DECL_THREADSAFE_ISUPPORTS
6166

@@ -64,10 +69,6 @@ class HttpData
6469
mThread = nullptr;
6570
}
6671

67-
virtual ~HttpData()
68-
{
69-
}
70-
7172
nsTArray<HttpRetParams> mData;
7273
nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
7374
nsIThread *mThread;
@@ -79,6 +80,10 @@ NS_IMPL_ISUPPORTS0(HttpData)
7980
class WebSocketRequest
8081
: public nsISupports
8182
{
83+
virtual ~WebSocketRequest()
84+
{
85+
}
86+
8287
public:
8388
NS_DECL_THREADSAFE_ISUPPORTS
8489

@@ -87,10 +92,6 @@ class WebSocketRequest
8792
mThread = nullptr;
8893
}
8994

90-
virtual ~WebSocketRequest()
91-
{
92-
}
93-
9495
nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
9596
nsIThread *mThread;
9697
};
@@ -101,6 +102,10 @@ NS_IMPL_ISUPPORTS0(WebSocketRequest)
101102
class DnsData
102103
: public nsISupports
103104
{
105+
virtual ~DnsData()
106+
{
107+
}
108+
104109
public:
105110
NS_DECL_THREADSAFE_ISUPPORTS
106111

@@ -109,10 +114,6 @@ class DnsData
109114
mThread = nullptr;
110115
}
111116

112-
virtual ~DnsData()
113-
{
114-
}
115-
116117
nsTArray<DNSCacheEntries> mData;
117118
nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
118119
nsIThread *mThread;
@@ -125,6 +126,13 @@ class ConnectionData
125126
: public nsITransportEventSink
126127
, public nsITimerCallback
127128
{
129+
virtual ~ConnectionData()
130+
{
131+
if (mTimer) {
132+
mTimer->Cancel();
133+
}
134+
}
135+
128136
public:
129137
NS_DECL_THREADSAFE_ISUPPORTS
130138
NS_DECL_NSITRANSPORTEVENTSINK
@@ -139,13 +147,6 @@ class ConnectionData
139147
mDashboard = target;
140148
}
141149

142-
virtual ~ConnectionData()
143-
{
144-
if (mTimer) {
145-
mTimer->Cancel();
146-
}
147-
}
148-
149150
nsCOMPtr<nsISocketTransport> mSocket;
150151
nsCOMPtr<nsIInputStream> mStreamIn;
151152
nsCOMPtr<nsITimer> mTimer;
@@ -228,6 +229,10 @@ class LookupHelper;
228229
class LookupArgument
229230
: public nsISupports
230231
{
232+
virtual ~LookupArgument()
233+
{
234+
}
235+
231236
public:
232237
NS_DECL_THREADSAFE_ISUPPORTS
233238

@@ -237,10 +242,6 @@ class LookupArgument
237242
mHelper = aHelper;
238243
}
239244

240-
virtual ~LookupArgument()
241-
{
242-
}
243-
244245
nsCOMPtr<nsIDNSRecord> mRecord;
245246
nsRefPtr<LookupHelper> mHelper;
246247
};
@@ -251,20 +252,20 @@ NS_IMPL_ISUPPORTS0(LookupArgument)
251252
class LookupHelper
252253
: public nsIDNSListener
253254
{
254-
public:
255-
NS_DECL_THREADSAFE_ISUPPORTS
256-
NS_DECL_NSIDNSLISTENER
257-
258-
LookupHelper() {
259-
}
260-
261255
virtual ~LookupHelper()
262256
{
263257
if (mCancel) {
264258
mCancel->Cancel(NS_ERROR_ABORT);
265259
}
266260
}
267261

262+
public:
263+
NS_DECL_THREADSAFE_ISUPPORTS
264+
NS_DECL_NSIDNSLISTENER
265+
266+
LookupHelper() {
267+
}
268+
268269
nsresult ConstructAnswer(LookupArgument *aArgument);
269270
public:
270271
nsCOMPtr<nsICancelable> mCancel;

netwerk/base/src/EventTokenBucket.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ class TokenBucketCancelable : public nsICancelable
3535
NS_DECL_NSICANCELABLE
3636

3737
TokenBucketCancelable(class ATokenBucketEvent *event);
38-
virtual ~TokenBucketCancelable() {}
3938
void Fire();
4039

4140
private:
41+
virtual ~TokenBucketCancelable() {}
42+
4243
friend class EventTokenBucket;
4344
ATokenBucketEvent *mEvent;
4445
};

netwerk/base/src/EventTokenBucket.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ class TokenBucketCancelable;
6969

7070
class EventTokenBucket : public nsITimerCallback
7171
{
72+
virtual ~EventTokenBucket();
73+
7274
public:
7375
NS_DECL_THREADSAFE_ISUPPORTS
7476
NS_DECL_NSITIMERCALLBACK
7577

7678
// This should be constructed on the main thread
7779
EventTokenBucket(uint32_t eventsPerSecond, uint32_t burstSize);
78-
virtual ~EventTokenBucket();
7980

8081
// These public methods are all meant to be called from the socket thread
8182
void ClearCredits();

netwerk/base/src/Predictor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class PredictorDNSListener : public nsIDNSListener
150150
PredictorDNSListener()
151151
{ }
152152

153+
private:
153154
virtual ~PredictorDNSListener()
154155
{ }
155156
};

netwerk/base/src/Predictor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ class Predictor : public nsINetworkPredictor
4949
NS_DECL_NSIINTERFACEREQUESTOR
5050

5151
Predictor();
52-
virtual ~Predictor();
5352

5453
nsresult Init();
5554
void Shutdown();
5655
static nsresult Create(nsISupports *outer, const nsIID& iid, void **result);
5756

5857
private:
58+
virtual ~Predictor();
59+
5960
friend class PredictionEvent;
6061
friend class LearnEvent;
6162
friend class PredictorResetEvent;

netwerk/base/src/ProxyAutoConfig.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ class PACResolver MOZ_FINAL : public nsIDNSListener
287287
nsCOMPtr<nsICancelable> mRequest;
288288
nsCOMPtr<nsIDNSRecord> mResponse;
289289
nsCOMPtr<nsITimer> mTimer;
290+
291+
private:
292+
~PACResolver() {}
290293
};
291294
NS_IMPL_ISUPPORTS(PACResolver, nsIDNSListener, nsITimerCallback)
292295

netwerk/base/src/RedirectChannelRegistrar.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class RedirectChannelRegistrar MOZ_FINAL : public nsIRedirectChannelRegistrar
2222

2323
RedirectChannelRegistrar();
2424

25+
private:
26+
~RedirectChannelRegistrar() {}
27+
2528
protected:
2629
typedef nsInterfaceHashtable<nsUint32HashKey, nsIChannel>
2730
ChannelHashtable;

netwerk/base/src/StreamingProtocolService.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ namespace net {
1919
*/
2020
class StreamingProtocolControllerService : public nsIStreamingProtocolControllerService
2121
{
22+
private:
23+
virtual ~StreamingProtocolControllerService() {};
24+
2225
public:
2326
NS_DECL_ISUPPORTS
2427
NS_DECL_NSISTREAMINGPROTOCOLCONTROLLERSERVICE
2528

2629
StreamingProtocolControllerService() {};
27-
virtual ~StreamingProtocolControllerService() {};
2830
static already_AddRefed<StreamingProtocolControllerService> GetInstance();
2931
};
3032
} // namespace dom

netwerk/base/src/Tickler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class Tickler MOZ_FINAL : public nsSupportsWeakReference
6666

6767
// These methods are main thread only
6868
Tickler();
69-
~Tickler();
7069
void Cancel();
7170
nsresult Init();
7271
void SetIPV4Address(uint32_t address);
@@ -77,6 +76,8 @@ class Tickler MOZ_FINAL : public nsSupportsWeakReference
7776
void Tickle();
7877

7978
private:
79+
~Tickler();
80+
8081
friend class TicklerTimer;
8182
Mutex mLock;
8283
nsCOMPtr<nsIThread> mThread;
@@ -110,11 +111,11 @@ NS_DEFINE_STATIC_IID_ACCESSOR(Tickler, NS_TICKLER_IID)
110111

111112
class Tickler MOZ_FINAL : public nsISupports
112113
{
114+
~Tickler() { }
113115
public:
114116
NS_DECL_THREADSAFE_ISUPPORTS
115117

116118
Tickler() { }
117-
~Tickler() { }
118119
nsresult Init() { return NS_ERROR_NOT_IMPLEMENTED; }
119120
void Cancel() { }
120121
void SetIPV4Address(uint32_t) { };

netwerk/base/src/nsAsyncStreamCopier.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class nsAsyncStreamCopier : public nsIAsyncStreamCopier, nsIAsyncStreamCopier2
3333
bool aCloseSink);
3434

3535
nsAsyncStreamCopier();
36-
virtual ~nsAsyncStreamCopier();
3736

3837
//-------------------------------------------------------------------------
3938
// these methods may be called on any thread
@@ -42,6 +41,8 @@ class nsAsyncStreamCopier : public nsIAsyncStreamCopier, nsIAsyncStreamCopier2
4241
void Complete(nsresult status);
4342

4443
private:
44+
virtual ~nsAsyncStreamCopier();
45+
4546
nsresult InitInternal(nsIInputStream *source,
4647
nsIOutputStream *sink,
4748
nsIEventTarget *target,

netwerk/base/src/nsAuthInformationHolder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
#include "nsString.h"
1111

1212
class nsAuthInformationHolder : public nsIAuthInformation {
13+
14+
protected:
15+
virtual ~nsAuthInformationHolder() {}
16+
1317
public:
1418
// aAuthType must be ASCII
1519
nsAuthInformationHolder(uint32_t aFlags, const nsString& aRealm,
1620
const nsCString& aAuthType)
1721
: mFlags(aFlags), mRealm(aRealm), mAuthType(aAuthType) {}
1822

19-
virtual ~nsAuthInformationHolder() {}
20-
2123
NS_DECL_ISUPPORTS
2224
NS_DECL_NSIAUTHINFORMATION
2325

netwerk/base/src/nsBufferedStreams.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ class nsBufferedStream : public nsISeekableStream
2424
NS_DECL_NSISEEKABLESTREAM
2525

2626
nsBufferedStream();
27-
virtual ~nsBufferedStream();
2827

2928
nsresult Close();
3029

3130
protected:
31+
virtual ~nsBufferedStream();
32+
3233
nsresult Init(nsISupports* stream, uint32_t bufferSize);
3334
NS_IMETHOD Fill() = 0;
3435
NS_IMETHOD Flush() = 0;

netwerk/base/src/nsDNSPrefetch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class nsIDNSService;
1818

1919
class nsDNSPrefetch MOZ_FINAL : public nsIDNSListener
2020
{
21+
~nsDNSPrefetch() {}
22+
2123
public:
2224
NS_DECL_THREADSAFE_ISUPPORTS
2325
NS_DECL_NSIDNSLISTENER

netwerk/base/src/nsFileStreams.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: 4 -*- */
1+
// /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
@@ -31,9 +31,10 @@ class nsFileStreamBase : public nsISeekableStream,
3131
NS_DECL_NSIFILEMETADATA
3232

3333
nsFileStreamBase();
34-
virtual ~nsFileStreamBase();
3534

3635
protected:
36+
virtual ~nsFileStreamBase();
37+
3738
nsresult Close();
3839
nsresult Available(uint64_t* _retval);
3940
nsresult Read(char* aBuf, uint32_t aCount, uint32_t* _retval);

netwerk/base/src/nsIOService.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,8 @@ nsIOService::ExtractCharsetFromContentType(const nsACString &aTypeHeader,
11791179
// nsISpeculativeConnect
11801180
class IOServiceProxyCallback MOZ_FINAL : public nsIProtocolProxyCallback
11811181
{
1182+
~IOServiceProxyCallback() {}
1183+
11821184
public:
11831185
NS_DECL_ISUPPORTS
11841186
NS_DECL_NSIPROTOCOLPROXYCALLBACK

0 commit comments

Comments
 (0)