mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
Avoid division by zero in the case of a corrupt estimates file
This commit is contained in:
parent
424be03305
commit
fe862c5ad4
1 changed files with 4 additions and 0 deletions
|
@ -180,6 +180,7 @@ TxConfirmStats::TxConfirmStats(const std::vector<double>& defaultBuckets,
|
||||||
: buckets(defaultBuckets), bucketMap(defaultBucketMap)
|
: buckets(defaultBuckets), bucketMap(defaultBucketMap)
|
||||||
{
|
{
|
||||||
decay = _decay;
|
decay = _decay;
|
||||||
|
assert(_scale != 0 && "_scale must be non-zero");
|
||||||
scale = _scale;
|
scale = _scale;
|
||||||
confAvg.resize(maxPeriods);
|
confAvg.resize(maxPeriods);
|
||||||
for (unsigned int i = 0; i < maxPeriods; i++) {
|
for (unsigned int i = 0; i < maxPeriods; i++) {
|
||||||
|
@ -418,6 +419,9 @@ void TxConfirmStats::Read(CAutoFile& filein, int nFileVersion, size_t numBuckets
|
||||||
throw std::runtime_error("Corrupt estimates file. Decay must be between 0 and 1 (non-inclusive)");
|
throw std::runtime_error("Corrupt estimates file. Decay must be between 0 and 1 (non-inclusive)");
|
||||||
}
|
}
|
||||||
filein >> scale;
|
filein >> scale;
|
||||||
|
if (scale == 0) {
|
||||||
|
throw std::runtime_error("Corrupt estimates file. Scale must be non-zero");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filein >> avg;
|
filein >> avg;
|
||||||
|
|
Loading…
Add table
Reference in a new issue