diff --git a/src/common/network/udp/Socket.cpp b/src/common/network/udp/Socket.cpp index ff0c282a..c4c6e7ba 100644 --- a/src/common/network/udp/Socket.cpp +++ b/src/common/network/udp/Socket.cpp @@ -531,8 +531,10 @@ bool Socket::write(BufferQueue* buffers, ssize_t* lenWritten) noexcept } // LogDebugEx(LOG_NET, "Socket::write()", "buffers len = %u", currentQueueSize); - if (currentQueueSize > UINT16_MAX) - currentQueueSize = UINT16_MAX; // only send up to this many buffers + if (currentQueueSize > MAX_BUFFER_COUNT) { + currentQueueSize = MAX_BUFFER_COUNT; // only send up to this many buffers + LogWarning(LOG_NET, "socket buffer queue backpressure >%d", MAX_BUFFER_COUNT); + } // are we crypto wrapped? if (m_isCryptoWrapped) { @@ -605,6 +607,7 @@ bool Socket::write(BufferQueue* buffers, ssize_t* lenWritten) noexcept cryptedLen += alignment; // reallocate buffer and copy + delete[] cryptoBuffer; cryptoBuffer = new uint8_t[cryptedLen]; ::memset(cryptoBuffer, 0x00U, cryptedLen); ::memcpy(cryptoBuffer, iov_buffer, length); diff --git a/src/common/p25/dfsi/frames/FullRateVoice.cpp b/src/common/p25/dfsi/frames/FullRateVoice.cpp index 1eab396f..676fd10b 100644 --- a/src/common/p25/dfsi/frames/FullRateVoice.cpp +++ b/src/common/p25/dfsi/frames/FullRateVoice.cpp @@ -89,7 +89,7 @@ bool FullRateVoice::decode(const uint8_t* data) assert(data != nullptr); if (imbeData != nullptr) - delete imbeData; + delete[] imbeData; imbeData = new uint8_t[IMBE_BUF_LEN]; ::memset(imbeData, 0x00U, IMBE_BUF_LEN); @@ -113,7 +113,7 @@ bool FullRateVoice::decode(const uint8_t* data) } } else { if (additionalData != nullptr) - delete additionalData; + delete[] additionalData; additionalData = nullptr; } @@ -137,6 +137,8 @@ void FullRateVoice::encode(uint8_t* data) (m_busy & 0x03U)); // Busy Status if (isVoice3thru8() || isVoice12thru17() || isVoice9or18()) { + if (additionalData == nullptr) + return; if (isVoice9or18()) { // CAI 9 and 18 are 3 bytes of additional data not 4 ::memcpy(data + 14U, additionalData, ADDITIONAL_LENGTH - 1U); diff --git a/src/common/p25/dfsi/frames/MotFullRateVoice.cpp b/src/common/p25/dfsi/frames/MotFullRateVoice.cpp index 462a4377..fcf16f10 100644 --- a/src/common/p25/dfsi/frames/MotFullRateVoice.cpp +++ b/src/common/p25/dfsi/frames/MotFullRateVoice.cpp @@ -95,7 +95,7 @@ bool MotFullRateVoice::decode(const uint8_t* data, bool shortened) assert(data != nullptr); if (imbeData != nullptr) - delete imbeData; + delete[] imbeData; imbeData = new uint8_t[RAW_IMBE_LENGTH_BYTES]; ::memset(imbeData, 0x00U, RAW_IMBE_LENGTH_BYTES); diff --git a/src/common/p25/dfsi/frames/fsc/FSCACK.cpp b/src/common/p25/dfsi/frames/fsc/FSCACK.cpp index 3661ab68..276caeed 100644 --- a/src/common/p25/dfsi/frames/fsc/FSCACK.cpp +++ b/src/common/p25/dfsi/frames/fsc/FSCACK.cpp @@ -51,14 +51,14 @@ bool FSCACK::decode(const uint8_t* data) if (m_respLength > 0) { if (responseData != nullptr) - delete responseData; + delete[] responseData; responseData = new uint8_t[m_respLength]; ::memset(responseData, 0x00U, m_respLength); ::memcpy(responseData, data + 7U, m_respLength); } else { if (responseData != nullptr) - delete responseData; + delete[] responseData; responseData = nullptr; } diff --git a/src/common/p25/lc/tdulc/LC_TDULC_RAW.cpp b/src/common/p25/lc/tdulc/LC_TDULC_RAW.cpp index 19fed6db..243dd78a 100644 --- a/src/common/p25/lc/tdulc/LC_TDULC_RAW.cpp +++ b/src/common/p25/lc/tdulc/LC_TDULC_RAW.cpp @@ -34,7 +34,7 @@ LC_TDULC_RAW::LC_TDULC_RAW() : TDULC(), LC_TDULC_RAW::~LC_TDULC_RAW() { if (m_tdulc != nullptr) { - delete m_tdulc; + delete[] m_tdulc; } } diff --git a/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp b/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp index 62947bdc..a664a20b 100644 --- a/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp +++ b/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp @@ -34,7 +34,7 @@ OSP_TSBK_RAW::OSP_TSBK_RAW() : TSBK(), OSP_TSBK_RAW::~OSP_TSBK_RAW() { if (m_tsbk != nullptr) { - delete m_tsbk; + delete[] m_tsbk; } }