Review feedback

- Use a lambda to defensively guarantee that "tx" can not affect the
  "signerCount" in "LoanSet::calculateBaseFee" # Please enter the commit
  message for your changes. Lines starting
This commit is contained in:
Ed Hennis
2025-11-22 16:14:54 -05:00
parent 973a105959
commit d353b0ec04

View File

@@ -159,9 +159,13 @@ LoanSet::calculateBaseFee(ReadView const& view, STTx const& tx)
// for the transaction. Note that unlike the base class, the single signer
// is counted if present. It will only be absent in a batch inner
// transaction.
std::size_t const signerCount = counterSig.isFieldPresent(sfSigners)
? counterSig.getFieldArray(sfSigners).size()
: (counterSig.isFieldPresent(sfTxnSignature) ? 1 : 0);
std::size_t const signerCount = [&counterSig]() {
// Compute defensively. Assure that "tx" cannot be accessed and cause
// confusion or miscalculations.
return counterSig.isFieldPresent(sfSigners)
? counterSig.getFieldArray(sfSigners).size()
: (counterSig.isFieldPresent(sfTxnSignature) ? 1 : 0);
}();
return normalCost + (signerCount * baseFee);
}