From: Tsuda Kageyu Date: Tue, 26 May 2015 02:54:57 +0000 (+0900) Subject: MPEG: Properties::xingHeader() should return null if a VBR header is not found. X-Git-Tag: v1.10beta~43^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f82be353b4c9a01f6352bb3dd89efeb49cf66512;p=taglib MPEG: Properties::xingHeader() should return null if a VBR header is not found. --- diff --git a/taglib/mpeg/mpegproperties.cpp b/taglib/mpeg/mpegproperties.cpp index 1e8bae5b..8cf330a3 100644 --- a/taglib/mpeg/mpegproperties.cpp +++ b/taglib/mpeg/mpegproperties.cpp @@ -178,10 +178,12 @@ void MPEG::Properties::read(File *file) file->seek(first + 4); d->xingHeader = new XingHeader(file->readBlock(firstHeader.frameLength() - 4)); + if(!d->xingHeader->isValid()) { + delete d->xingHeader; + d->xingHeader = 0; + } - if(d->xingHeader->isValid() && - firstHeader.samplesPerFrame() > 0 && - firstHeader.sampleRate() > 0) { + if(d->xingHeader && firstHeader.samplesPerFrame() > 0 && firstHeader.sampleRate() > 0) { // Read the length and the bitrate from the VBR header. diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp index 77bb2248..8d49a8c7 100644 --- a/tests/test_mpeg.cpp +++ b/tests/test_mpeg.cpp @@ -79,7 +79,7 @@ public: CPPUNIT_ASSERT_EQUAL(64, f.audioProperties()->bitrate()); CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channels()); CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate()); - CPPUNIT_ASSERT(!f.audioProperties()->xingHeader()->isValid()); + CPPUNIT_ASSERT(!f.audioProperties()->xingHeader()); long last = f.lastFrameOffset();