Skip to content

Commit

Permalink
Merge pull request #4408 from uklotzde/encoder-memleak
Browse files Browse the repository at this point in the history
EncoderFdkAac: Prevent accidental double delete/free
  • Loading branch information
Be-ing authored Oct 13, 2021
2 parents 2391045 + 5b9e1d1 commit dc88c79
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/encoder/encoderfdkaac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ int EncoderFdkAac::initEncoder(int samplerate, QString* pUserErrorMessage) {
aacEncOpen(&m_aacEnc, 0, m_channels);
VERIFY_OR_DEBUG_ASSERT(!m_pAacDataBuffer) {
delete[] m_pAacDataBuffer;
m_pAacDataBuffer = nullptr;
}
m_pAacDataBuffer = new unsigned char[kOutBufferBits * m_channels]();

Expand Down Expand Up @@ -351,11 +352,13 @@ int EncoderFdkAac::initEncoder(int samplerate, QString* pUserErrorMessage) {
// the Live Broadcasting implementation
VERIFY_OR_DEBUG_ASSERT(!m_pInputFifo) {
delete m_pInputFifo;
m_pInputFifo = nullptr;
}
m_pInputFifo = new FIFO<SAMPLE>(EngineSideChain::SIDECHAIN_BUFFER_SIZE * 2);

VERIFY_OR_DEBUG_ASSERT(!m_pFifoChunkBuffer) {
delete[] m_pFifoChunkBuffer;
m_pFifoChunkBuffer = nullptr;
}
m_pFifoChunkBuffer = new SAMPLE[m_readRequired * sizeof(SAMPLE)]();
return 0;
Expand Down

0 comments on commit dc88c79

Please sign in to comment.