]> granicus.if.org Git - taglib/commitdiff
Make sure to not try dividing by zero
authorLukáš Lalinský <lalinsky@gmail.com>
Sun, 4 Mar 2012 10:51:05 +0000 (11:51 +0100)
committerLukáš Lalinský <lalinsky@gmail.com>
Sun, 4 Mar 2012 10:51:05 +0000 (11:51 +0100)
taglib/ape/apeproperties.cpp

index aab9d25cf44ce61aaf50d3772ec8bad39227085a..4f14d6c5eca4ee38afa146fa897e8af19e48485a 100644 (file)
@@ -193,7 +193,7 @@ void APE::Properties::analyzeCurrent()
   uint blocksPerFrame = header.mid(4, 4).toUInt(false);
   uint finalFrameBlocks = header.mid(8, 4).toUInt(false);
   uint totalBlocks = totalFrames > 0 ? (totalFrames -  1) * blocksPerFrame + finalFrameBlocks : 0;
-  d->length = totalBlocks / d->sampleRate;
+  d->length = d->sampleRate > 0 ? totalBlocks / d->sampleRate : 0;
   d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
 }