diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2017-10-14 16:55:54 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2017-10-14 16:58:13 -0700 |
commit | 6ab0e4cf49549640b903bf5fce0e6035b8116397 (patch) | |
tree | 4e01698848693b6c91804674d5b50843758ddf9f | |
parent | 326a5652e0d25fdb60c337ef4f1c98a63e0748f0 (diff) | |
parent | fe862c5ad4bdce6bcc3bf8712d9472561b270c02 (diff) |
Merge #10672: Avoid division by zero in the case of a corrupt estimates file
fe862c5ad 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
-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; |