]> granicus.if.org Git - taglib/commitdiff
Don't crash when wav files have a 0 for bit per channel (sampleWidth)
authorStephen F. Booth <me@sbooth.org>
Thu, 28 Jul 2011 12:36:14 +0000 (08:36 -0400)
committerLukáš Lalinský <lalinsky@gmail.com>
Sat, 10 Mar 2012 07:58:45 +0000 (08:58 +0100)
I've seen this in a wav that has an audio format of MP3 (0x55)

taglib/riff/aiff/aiffproperties.cpp

index 77c3d2776077044bff8e44c7b858d916330e285a..afb741b77ef664bd98b0658f0228f8d53e53c71b 100644 (file)
@@ -149,5 +149,5 @@ void RIFF::AIFF::Properties::read(const ByteVector &data)
   double sampleRate = ConvertFromIeeeExtended(reinterpret_cast<unsigned char *>(data.mid(8, 10).data()));
   d->sampleRate     = sampleRate;
   d->bitrate        = (sampleRate * d->sampleWidth * d->channels) / 1000.0;
-  d->length         = sampleFrames / d->sampleRate;
+  d->length         = d->sampleRate > 0 ? sampleFrames / d->sampleRate : 0;
 }