[TurnPort] Check if turn entry was found when deleting a connection.

This is a simple way to avoid crashing, but the underlying issue
of why the entry has been removed, is a bit more complex to fix
and will be fixed in a follow-up CL.

Bug: chromium:1374310
Change-Id: I9dc0cf9e1acdcc3b3a205104346cc835b3f79c1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279283
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38405}
diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc
index 8023659..c8b7f30 100644
--- a/p2p/base/turn_port.cc
+++ b/p2p/base/turn_port.cc
@@ -1277,7 +1277,15 @@
   // already destroyed.
   const rtc::SocketAddress& remote_address = conn->remote_candidate().address();
   TurnEntry* entry = FindEntry(remote_address);
-  RTC_DCHECK(entry != NULL);
+  if (!entry) {
+    // TODO(chromium:1374310): This happens because more than one connection
+    // may be associated with an entry. Previously a connection with the same
+    // address has been destroyed and subsequently the entry removed
+    // (prematurely.)
+    RTC_DLOG_F(LS_WARNING) << "Entry has been removed.";
+    return;
+  }
+
   RTC_DCHECK(!entry->destruction_timestamp().has_value());
   int64_t timestamp = rtc::TimeMillis();
   entry->set_destruction_timestamp(timestamp);