]> granicus.if.org Git - taglib/commitdiff
MPEG: Properties::xingHeader() should return null if a VBR header is not found.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 26 May 2015 02:54:57 +0000 (11:54 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 18 Jun 2015 08:14:12 +0000 (17:14 +0900)
taglib/mpeg/mpegproperties.cpp
tests/test_mpeg.cpp

index 1e8bae5bd66c7394ed3ec491e3c6b7804fd8ff36..8cf330a38f8e066b6bb9044c20a3db543b89e4b2 100644 (file)
@@ -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.
 
index 77bb22481c84824e2ff7ff547de57b4cabaf4e9e..8d49a8c7b039ae708c27b6ad2b904e514410c556 100644 (file)
@@ -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();