lmi-commits
[Top][All Lists]
Advanced

[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;
             }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]