Add a guard against double delete to Connection::Destroy

Bug: webrtc:13752
Change-Id: I80345fe2e560773f9f98f850def386ec53ae798f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252660
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36085}
This commit is contained in:
Tomas Gunnarsson 2022-02-25 23:36:24 +01:00 committed by WebRTC LUCI CQ
parent a33a28f360
commit 7c2e958711
2 changed files with 8 additions and 0 deletions

View File

@ -834,6 +834,11 @@ void Connection::Prune() {
void Connection::Destroy() {
RTC_DCHECK_RUN_ON(network_thread_);
if (pending_delete_)
return;
pending_delete_ = true;
RTC_DLOG(LS_VERBOSE) << ToString() << ": Connection destroyed";
// Fire the 'destroyed' event before deleting the object. This is done

View File

@ -366,6 +366,9 @@ class Connection : public CandidatePairInterface, public sigslot::has_slots<> {
rtc::RateTracker recv_rate_tracker_;
rtc::RateTracker send_rate_tracker_;
int64_t last_send_data_ = 0;
// Set to true when deletion has been scheduled and must not be done again.
// See `Destroy()` for more details.
bool pending_delete_ RTC_GUARDED_BY(network_thread_) = false;
private:
// Update the local candidate based on the mapped address attribute.