From 7ba87f072851ab8a6fafb92d3ddb69ed3a044fb9 Mon Sep 17 00:00:00 2001 From: Daniel Nicoara Date: Thu, 5 Mar 2026 16:54:51 -0500 Subject: [PATCH] Fix use-of-uninitialized error in TCP.h (#43492) `mConnectionsBuffer` cannot be accessed by TCPBase during destruction since the derived class is destroyed first. (cherry picked from commit 51cc1ed4441387866505aba3808c660f1e65d2d6) --- src/transport/raw/TCP.cpp | 6 +----- src/transport/raw/TCP.h | 8 +++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/transport/raw/TCP.cpp b/src/transport/raw/TCP.cpp index cd4571ec145041..d8e9662f5cace7 100644 --- a/src/transport/raw/TCP.cpp +++ b/src/transport/raw/TCP.cpp @@ -53,11 +53,7 @@ constexpr int kListenBacklogSize = 2; } // namespace -TCPBase::~TCPBase() -{ - // Call Close to free the listening socket and close all active connections. - Close(); -} +TCPBase::~TCPBase() = default; void TCPBase::CloseActiveConnections() { diff --git a/src/transport/raw/TCP.h b/src/transport/raw/TCP.h index 4cd63b2b56260e..02375458119fba 100644 --- a/src/transport/raw/TCP.h +++ b/src/transport/raw/TCP.h @@ -338,7 +338,13 @@ class TCP : public TCPBase } } - ~TCP() override { mPendingPackets.ReleaseAll(); } + ~TCP() override + { + mPendingPackets.ReleaseAll(); + + // Call Close to free the listening socket and close all active connections. + Close(); + } private: ActiveTCPConnectionState mConnectionsBuffer[kActiveConnectionsSize];