Bug 1028588 - Fix dangerous public destructors in media/mtransport - r=abr

This commit is contained in:
Benoit Jacob 2014-06-24 12:36:44 -04:00
parent d51ba204fb
commit 451139b088
9 changed files with 30 additions and 15 deletions

View File

@ -130,10 +130,6 @@ class NrSocket : public NrSocketBase,
public nsASocketHandler {
public:
NrSocket() : fd_(nullptr) {}
virtual ~NrSocket() {
if (fd_)
PR_Close(fd_);
}
// Implement nsASocket
virtual void OnSocketReady(PRFileDesc *fd, int16_t outflags);
@ -165,6 +161,11 @@ public:
virtual int read(void* buf, size_t maxlen, size_t *len);
private:
virtual ~NrSocket() {
if (fd_)
PR_Close(fd_);
}
DISALLOW_COPY_ASSIGN(NrSocket);
PRFileDesc *fd_;
@ -202,7 +203,6 @@ public:
NS_DECL_NSIUDPSOCKETINTERNAL
NrSocketIpc(const nsCOMPtr<nsIEventTarget> &main_thread);
virtual ~NrSocketIpc() {};
// Implementations of the NrSocketBase APIs
virtual int create(nr_transport_addr *addr);
@ -218,6 +218,8 @@ public:
virtual int read(void* buf, size_t maxlen, size_t *len);
private:
virtual ~NrSocketIpc() {};
DISALLOW_COPY_ASSIGN(NrSocketIpc);
// Main thread executors of the NrSocketBase APIs

View File

@ -97,7 +97,6 @@ class NrIceResolver
transport_(transport),
cb_(cb), cb_arg_(cb_arg),
canceled_ (false) {}
virtual ~PendingResolution(){};
NS_IMETHOD OnLookupComplete(nsICancelable *request, nsIDNSRecord *record,
nsresult status);
int cancel();
@ -105,6 +104,7 @@ class NrIceResolver
NS_DECL_THREADSAFE_ISUPPORTS
private:
virtual ~PendingResolution(){};
nsCOMPtr<nsIEventTarget> thread_;
uint16_t port_;
int transport_;

View File

@ -81,12 +81,12 @@ class STUNUDPSocketFilter : public nsIUDPSocketFilter {
: white_list_(),
pending_requests_() {}
virtual ~STUNUDPSocketFilter() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIUDPSOCKETFILTER
private:
virtual ~STUNUDPSocketFilter() {}
bool filter_incoming_packet(const mozilla::net::NetAddr *remote_addr,
const uint8_t *data,
uint32_t len);

View File

@ -12,9 +12,10 @@
class nsStunUDPSocketFilterHandler : public nsIUDPSocketFilterHandler {
public:
virtual ~nsStunUDPSocketFilterHandler() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIUDPSOCKETFILTERHANDLER
private:
virtual ~nsStunUDPSocketFilterHandler() {}
};

View File

@ -47,12 +47,13 @@ class SendPeriodic : public nsITimerCallback {
SendPeriodic(TransportTestPeer *peer, int to_send) :
peer_(peer),
to_send_(to_send) {}
virtual ~SendPeriodic() {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITIMERCALLBACK
protected:
virtual ~SendPeriodic() {}
TransportTestPeer *peer_;
int to_send_;
};

View File

@ -109,7 +109,6 @@ class SocketHandler : public nsASocketHandler {
public:
SocketHandler(SocketTransportServiceTest *test) : test_(test) {
}
virtual ~SocketHandler() {}
void OnSocketReady(PRFileDesc *fd, int16_t outflags) {
unsigned char buf[1600];
@ -134,6 +133,9 @@ class SocketHandler : public nsASocketHandler {
NS_DECL_ISUPPORTS
protected:
virtual ~SocketHandler() {}
private:
SocketTransportServiceTest *test_;
};

View File

@ -139,5 +139,13 @@ class TransportFlow : public nsISupports,
nsCOMPtr<nsIEventTarget> target_;
};
// Temporary whitelist for dangerous public destructors of reference-counted
// classes. See Bug 1029478 for this occurrence.
template<>
struct HasDangerousPublicDestructor<TransportFlow>
{
static const bool value = true;
};
} // close namespace
#endif

View File

@ -109,8 +109,6 @@ class TransportLayerLoopback : public TransportLayer {
public:
Deliverer(TransportLayerLoopback *layer) :
layer_(layer) {}
virtual ~Deliverer() {
}
void Detach() {
layer_ = nullptr;
}
@ -119,6 +117,9 @@ class TransportLayerLoopback : public TransportLayer {
NS_DECL_NSITIMERCALLBACK
private:
virtual ~Deliverer() {
}
DISALLOW_COPY_ASSIGN(Deliverer);
TransportLayerLoopback *layer_;

View File

@ -56,7 +56,6 @@ class TransportLayerPrsock : public TransportLayer {
prsock_(prsock), fd_(fd) {
mPollFlags = PR_POLL_READ;
}
virtual ~SocketHandler() {}
void Detach() {
mCondition = NS_BASE_STREAM_CLOSED;
@ -92,7 +91,8 @@ class TransportLayerPrsock : public TransportLayer {
TransportLayerPrsock *prsock_;
PRFileDesc *fd_;
private:
DISALLOW_COPY_ASSIGN(SocketHandler);
DISALLOW_COPY_ASSIGN(SocketHandler);
virtual ~SocketHandler() {}
};
// Allow SocketHandler to talk to our APIs