From abe1b52d18d2e271eb77c4936270cd65bf2d642b Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sat, 16 Aug 2025 11:41:43 +0200 Subject: [PATCH] fix potential acces violation --- Common/DCSProtocolHandlerPool.cpp | 5 +++-- Common/DExtraProtocolHandlerPool.cpp | 3 ++- Common/DPlusProtocolHandlerPool.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Common/DCSProtocolHandlerPool.cpp b/Common/DCSProtocolHandlerPool.cpp index fd10f0f..f8fdf7a 100644 --- a/Common/DCSProtocolHandlerPool.cpp +++ b/Common/DCSProtocolHandlerPool.cpp @@ -80,11 +80,12 @@ void CDCSProtocolHandlerPool::release(CDCSProtocolHandler *handler) assert(handler != NULL); for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { if (it->second == handler) { + unsigned int port = handler->getPort(); m_pool.erase(it); handler->close(); delete handler ; - m_index = m_pool.end(); // since we removed an element, m_index is ouot of order, just move it back to the end - CLog::logInfo("Released DCS ProtocolHandler on port %u.\n", handler->getPort()); + m_index = m_pool.end(); // since we removed an element, m_index is out of order, just move it back to the end + CLog::logInfo("Released DCS ProtocolHandler on port %u.\n", port); return; } diff --git a/Common/DExtraProtocolHandlerPool.cpp b/Common/DExtraProtocolHandlerPool.cpp index c726259..3704850 100644 --- a/Common/DExtraProtocolHandlerPool.cpp +++ b/Common/DExtraProtocolHandlerPool.cpp @@ -80,11 +80,12 @@ void CDExtraProtocolHandlerPool::release(CDExtraProtocolHandler *handler) assert(handler != NULL); for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { if (it->second == handler) { + unsigned int port = handler->getPort(); m_pool.erase(it); handler->close(); delete handler; m_index = m_pool.end(); // m_index might be out of order, reset it - CLog::logInfo("Releasing DExtra Protocol Handler on port %u.\n", handler->getPort()); + CLog::logInfo("Releasing DExtra Protocol Handler on port %u.\n", port); return; } diff --git a/Common/DPlusProtocolHandlerPool.cpp b/Common/DPlusProtocolHandlerPool.cpp index 1b62276..ed8d63a 100644 --- a/Common/DPlusProtocolHandlerPool.cpp +++ b/Common/DPlusProtocolHandlerPool.cpp @@ -81,11 +81,12 @@ void CDPlusProtocolHandlerPool::release(CDPlusProtocolHandler *handler) assert(handler != NULL); for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { if (it->second == handler) { + unsigned int port = handler->getPort(); m_pool.erase(it); handler->close(); delete handler; m_index = m_pool.end(); // m_index might be ut of order so reset it - CLog::logInfo("Releasing DPlus ProtocolHandler on port %u.\n", handler->getPort()); + CLog::logInfo("Releasing DPlus ProtocolHandler on port %u.\n", port); return; } }