From f82be353b4c9a01f6352bb3dd89efeb49cf66512 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Tue, 26 May 2015 11:54:57 +0900 Subject: [PATCH] MPEG: Properties::xingHeader() should return null if a VBR header is not found. --- taglib/mpeg/mpegproperties.cpp | 8 +++++--- tests/test_mpeg.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) 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(); -- 2.40.0