Skip to content

Commit 6ab0e4c

Browse files
committed
Merge #10672: Avoid division by zero in the case of a corrupt estimates file
fe862c5 Avoid division by zero in the case of a corrupt estimates file (practicalswift) Pull request description: Avoid division by zero in the case of a corrupt estimates file. Tree-SHA512: 285cb0d566f239d260880026a930a7412d86e31ea3819d5371a36364a241dc76164e68c1da6da8369345fa6037ca0abc5ab82d245058c085d5f1fd50111fba48
2 parents 326a565 + fe862c5 commit 6ab0e4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/policy/fees.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ TxConfirmStats::TxConfirmStats(const std::vector<double>& defaultBuckets,
180180
: buckets(defaultBuckets), bucketMap(defaultBucketMap)
181181
{
182182
decay = _decay;
183+
assert(_scale != 0 && "_scale must be non-zero");
183184
scale = _scale;
184185
confAvg.resize(maxPeriods);
185186
for (unsigned int i = 0; i < maxPeriods; i++) {
@@ -418,6 +419,9 @@ void TxConfirmStats::Read(CAutoFile& filein, int nFileVersion, size_t numBuckets
418419
throw std::runtime_error("Corrupt estimates file. Decay must be between 0 and 1 (non-inclusive)");
419420
}
420421
filein >> scale;
422+
if (scale == 0) {
423+
throw std::runtime_error("Corrupt estimates file. Scale must be non-zero");
424+
}
421425
}
422426

423427
filein >> avg;

0 commit comments

Comments
 (0)