# HG changeset patch # User Chris Cannam # Date 1488821843 0 # Node ID aadfb395e9332a40a4ba2fe33fb7039be96ceeb4 # Parent cc62d7862203fb02da016fc0df556872dc54b190 Fix some one-off memory leaks (including distracting ones in tests) diff -r cc62d7862203 -r aadfb395e933 data/fileio/AudioFileSizeEstimator.cpp --- a/data/fileio/AudioFileSizeEstimator.cpp Mon Mar 06 17:23:46 2017 +0000 +++ b/data/fileio/AudioFileSizeEstimator.cpp Mon Mar 06 17:37:23 2017 +0000 @@ -42,7 +42,6 @@ if (targetRate != 0.0 && targetRate != rate) { samples = sv_frame_t(double(samples) * targetRate / rate); } - delete reader; SVDEBUG << "AudioFileSizeEstimator: WAV file reader accepts this file, reports " << samples << " samples" << endl; estimate = samples; @@ -51,6 +50,9 @@ << "estimating from file size and extension instead" << endl; } + delete reader; + reader = 0; + if (estimate == 0) { // The remainder just makes an estimate based on the file size diff -r cc62d7862203 -r aadfb395e933 data/fileio/MP3FileReader.cpp --- a/data/fileio/MP3FileReader.cpp Mon Mar 06 17:23:46 2017 +0000 +++ b/data/fileio/MP3FileReader.cpp Mon Mar 06 17:37:23 2017 +0000 @@ -136,6 +136,14 @@ if (!decode(m_fileBuffer, m_fileBufferSize)) { m_error = QString("Failed to decode file %1.").arg(m_path); } + + if (m_sampleBuffer) { + for (int c = 0; c < m_channelCount; ++c) { + delete[] m_sampleBuffer[c]; + } + delete[] m_sampleBuffer; + m_sampleBuffer = 0; + } delete[] m_fileBuffer; m_fileBuffer = 0; diff -r cc62d7862203 -r aadfb395e933 data/fileio/test/AudioFileReaderTest.h --- a/data/fileio/test/AudioFileReaderTest.h Mon Mar 06 17:23:46 2017 +0000 +++ b/data/fileio/test/AudioFileReaderTest.h Mon Mar 06 17:37:23 2017 +0000 @@ -287,6 +287,10 @@ // expected number back (if this is not mp3/aac) or (b) take // into account silence at beginning and end (if it is). floatvec_t test = reader->getInterleavedFrames(0, refFrames + 5000); + + delete reader; + reader = 0; + sv_frame_t read = test.size() / channels; bool perceptual = (extension == "mp3" || diff -r cc62d7862203 -r aadfb395e933 data/fileio/test/EncodingTest.h --- a/data/fileio/test/EncodingTest.h Mon Mar 06 17:23:46 2017 +0000 +++ b/data/fileio/test/EncodingTest.h Mon Mar 06 17:37:23 2017 +0000 @@ -107,6 +107,8 @@ (encodingDir + "/" + audiofile, params); QVERIFY(reader != nullptr); + + delete reader; } void readMetadata_data() { @@ -132,7 +134,13 @@ QString file = fileAndExt[0]; QString extension = fileAndExt[1]; - if (extension != "wav") { + if (extension == "wav") { + + // Nothing + + delete reader; + + } else { #if (!defined (HAVE_OGGZ) || !defined(HAVE_FISHSOUND)) if (extension == "ogg") { @@ -145,6 +153,8 @@ QString title = reader->getTitle(); QVERIFY(title != QString()); + delete reader; + bool found = false; for (int m = 0; m < mappingCount; ++m) { if (file == QString::fromUtf8(mapping[m][0])) { diff -r cc62d7862203 -r aadfb395e933 data/midi/rtmidi/RtMidi.cpp --- a/data/midi/rtmidi/RtMidi.cpp Mon Mar 06 17:23:46 2017 +0000 +++ b/data/midi/rtmidi/RtMidi.cpp Mon Mar 06 17:37:23 2017 +0000 @@ -39,6 +39,9 @@ #include "RtMidi.h" #include +// CC be gung-ho about this here, assume upstream has it in hand +#pragma GCC diagnostic ignored "-Wconversion" + #if defined(__MACOSX_CORE__) #if TARGET_OS_IPHONE #define AudioGetCurrentHostTime CAHostTimeBase::GetCurrentTime