Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Unified Diff: webrtc/p2p/base/transportcontroller.h

Issue 2571683004: Fixing possible crash due to RefCountedChannel assignment operator. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/transportcontroller.h
diff --git a/webrtc/p2p/base/transportcontroller.h b/webrtc/p2p/base/transportcontroller.h
index cdac4b6dcb5e72a08761a593b02d2f5fae9812c5..921d5508a110f0f1a87789273eaaef61fa936a98 100644
--- a/webrtc/p2p/base/transportcontroller.h
+++ b/webrtc/p2p/base/transportcontroller.h
@@ -17,6 +17,7 @@
#include <vector>
#include "webrtc/base/asyncinvoker.h"
+#include "webrtc/base/constructormagic.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/p2p/base/candidate.h"
@@ -170,10 +171,21 @@ class TransportController : public sigslot::has_slots<>,
// TODO(deadbeef): Change the types of |dtls| and |ice| to
// DtlsTransportChannelWrapper and P2PTransportChannelWrapper,
// once TransportChannelImpl is removed.
- explicit RefCountedChannel(TransportChannelImpl* dtls,
- TransportChannelImpl* ice)
+ RefCountedChannel(TransportChannelImpl* dtls, TransportChannelImpl* ice)
honghaiz3 2016/12/13 19:02:20 Why do we implement our custom RefCounted class in
Taylor Brandstetter 2016/12/13 22:42:36 I think just because no one has bothered to change
: ice_(ice), dtls_(dtls), ref_(0) {}
+ // Move assignment operator and move constructor needed since this goes in
+ // a vector.
+ RefCountedChannel(RefCountedChannel&& o)
+ : ice_(std::move(o.ice_)), dtls_(std::move(o.dtls_)), ref_(o.ref_) {
+ }
+ void operator=(RefCountedChannel&& o) {
+ // Need to delete the DTLS channel first since it depends on ICE.
honghaiz3 2016/12/13 19:02:20 I wonder if we can better solve the dependency by
Taylor Brandstetter 2016/12/13 22:42:36 We can discuss that separately, but I don't want t
+ dtls_ = std::move(o.dtls_);
+ ice_ = std::move(o.ice_);
+ ref_ = o.ref_;
+ }
+
void AddRef() { ++ref_; }
void DecRef() {
ASSERT(ref_ > 0);
@@ -282,6 +294,8 @@ class TransportController : public sigslot::has_slots<>,
bool quic_ = false;
webrtc::MetricsObserverInterface* metrics_observer_ = nullptr;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(TransportController);
};
} // namespace cricket
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698