Always explicitly check for divide by zero conditions.

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@335132 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler
2004-08-02 12:51:14 +00:00
parent 650b561eda
commit ae2113e716
4 changed files with 9 additions and 12 deletions

View File

@ -133,8 +133,8 @@ void MPC::Properties::read()
}
unsigned int samples = frames * 1152 - 576;
d->length = (samples + (d->sampleRate / 2)) / d->sampleRate;
d->length = d->sampleRate > 0 ? (samples + (d->sampleRate / 2)) / d->sampleRate : 0;
if(!d->bitrate)
d->bitrate = ((d->streamLength * 8L) / d->length) / 1000;
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
}