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

Unified Diff: webrtc/p2p/base/turnport.cc

Issue 1458013004: Make it extra safe when deleting a turn entry. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 1 month 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 | « webrtc/p2p/base/turnport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/turnport.cc
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc
index 5e88365a83d615bdbc2e19ffe62694444ee20039..a1a13cbc01454dd040db89dde3c8cdce68c189ce 100644
--- a/webrtc/p2p/base/turnport.cc
+++ b/webrtc/p2p/base/turnport.cc
@@ -907,6 +907,11 @@ TurnEntry* TurnPort::FindEntry(int channel_id) const {
return (it != entries_.end()) ? *it : NULL;
}
+bool TurnPort::EntryExists(TurnEntry* e) {
+ auto it = std::find(entries_.begin(), entries_.end(), e);
+ return it != entries_.end();
+}
+
void TurnPort::CreateOrRefreshEntry(const rtc::SocketAddress& addr) {
TurnEntry* entry = FindEntry(addr);
if (entry == nullptr) {
@@ -928,6 +933,9 @@ void TurnPort::DestroyEntry(TurnEntry* entry) {
void TurnPort::DestroyEntryIfNotCancelled(TurnEntry* entry,
uint32_t timestamp) {
+ if (!EntryExists(entry)) {
+ return;
+ }
bool cancelled = timestamp != entry->destruction_timestamp();
if (!cancelled) {
DestroyEntry(entry);
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698