diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2017-06-26 16:00:25 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2017-10-13 08:41:45 +0200 |
commit | fe862c5ad4bdce6bcc3bf8712d9472561b270c02 (patch) | |
tree | 574c5a4e1f4c2c4651b4ad5d89cc59257eedea71 /src | |
parent | 424be03305143cbe5da5d5adb54d73d3dc3747b6 (diff) | |
download | bitcoin-fe862c5ad4bdce6bcc3bf8712d9472561b270c02.tar.xz |
Avoid division by zero in the case of a corrupt estimates file
Diffstat (limited to 'src')
-rw-r--r-- | src/policy/fees.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index dcf49de5f1..c7e57671c0 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -180,6 +180,7 @@ TxConfirmStats::TxConfirmStats(const std::vector<double>& defaultBuckets, : buckets(defaultBuckets), bucketMap(defaultBucketMap) { decay = _decay; + assert(_scale != 0 && "_scale must be non-zero"); scale = _scale; confAvg.resize(maxPeriods); 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)"); } filein >> scale; + if (scale == 0) { + throw std::runtime_error("Corrupt estimates file. Scale must be non-zero"); + } } filein >> avg; |