- BUGFIX: Fixed possible overflow in ETA calculation

This commit is contained in:
Christophe Dumez
2007-11-21 19:01:24 +00:00
parent df92e3e5e9
commit 6b6d05a380
2 changed files with 11 additions and 3 deletions

View File

@@ -166,8 +166,16 @@ void bittorrent::updateETAs() {
foreach(val, listEtas) {
moy += (qlonglong)((double)val/(double)nbETAs);
}
Q_ASSERT(moy >= 0);
ETAs[hash] = moy;
if(moy < 0) {
if(ETAstats.contains(hash)) {
ETAstats.remove(hash);
}
if(ETAs.contains(hash)) {
ETAs.remove(hash);
}
} else {
ETAs[hash] = moy;
}
} else {
// Speed is too low, we don't want an overflow.
if(ETAstats.contains(hash)) {