Correct handling of LoanBroker.DebtMaximum zero values

- Addresses FIND-003 from audit.
- Behavior changed to treat a DebtMaximum value of 0 to mean "no limit",
  as defined in spec.
- No need to add unit tests, because the previous commit covers 0, and
  tests already exist for non-zero limits.
This commit is contained in:
Ed Hennis
2025-07-30 17:38:15 -04:00
parent a1e9091f1e
commit d58399d417

View File

@@ -243,7 +243,8 @@ LoanSet::preclaim(PreclaimContext const& ctx)
return tecINSUFFICIENT_FUNDS;
}
auto const newDebtTotal = brokerSle->at(sfDebtTotal) + principalRequested;
if (brokerSle->at(sfDebtMaximum) < newDebtTotal)
if (auto const debtMaximum = brokerSle->at(sfDebtMaximum);
debtMaximum != 0 && debtMaximum < newDebtTotal)
{
JLOG(ctx.j.warn())
<< "Loan would exceed the maximum debt limit of the LoanBroker.";