[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 8aea003 2/8: Fix defect introduced 20050114T1
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 8aea003 2/8: Fix defect introduced 20050114T1947Z: range error |
Date: |
Mon, 31 Jul 2017 17:24:17 -0400 (EDT) |
branch: master
commit 8aea0033684792b3cb5ec3877c58d56b8b1a648d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Fix defect introduced 20050114T1947Z: range error
Vectors were accessed with negative offsets when printing the age-70 row
for issue ages over 70. Limiting the offset '69 - age' to a maximum of
99 did nothing, because age is nonnegative and 69 minus a nonnegative
number is certainly less than 99 (and the hard-coded limit of 99 was
wrong anyway). Removed that nonsense and imposed a minimum of zero.
---
ledger_text_formats.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/ledger_text_formats.cpp b/ledger_text_formats.cpp
index 2ccba43..2e55683 100644
--- a/ledger_text_formats.cpp
+++ b/ledger_text_formats.cpp
@@ -1029,13 +1029,14 @@ void FlatTextLedgerPrinter::PrintNumericalSummary()
const
os_ << " Year Outlay Value Value Benefit
Value Value Benefit Value Value Benefit" << endrow;
os_ << endrow;
- int summary_rows[] = {4, 9, 19, std::min(99, 69 -
value_cast<int>(invar().Age))};
+ int summary_rows[] = {4, 9, 19, 69 - value_cast<int>(invar().Age)};
for(auto const& row : summary_rows)
{
- // Skip row if it doesn't exist. For instance, if issue age is
- // 85 and maturity age is 100, then there is no twentieth duration.
- if(ledger_.GetMaxLength() < 1 + row)
+ // Skip row if it doesn't exist. For instance, if the issue
+ // age is 85 and the contract remains in force until age 100,
+ // then there is no twentieth duration and no age-70 row.
+ if(!(0 <= row && row < ledger_.GetMaxLength()))
{
continue;
}
- [lmi-commits] [lmi] master updated (e13aa72 -> bd7e567), Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 6ceeaf8 1/8: Say why headers are included if not obvious, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 8aea003 2/8: Fix defect introduced 20050114T1947Z: range error,
Greg Chicares <=
- [lmi-commits] [lmi] master 5df1ad4 4/8: Resolve several marked defects [384], Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 9051064 3/8: Improve label on age-70 row in Numeric Summary [388], Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 9edce5a 5/8: Crudely paginate text output, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 615758f 6/8: Improve const-correctness, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master bd7e567 8/8: Show lapse years in Numeric Summary, Greg Chicares, 2017/07/31
- [lmi-commits] [lmi] master 1622e2f 7/8: Locally cache certain values, Greg Chicares, 2017/07/31