From d353b0ec040769518c2c752abf92b84382ed3e17 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Sat, 22 Nov 2025 16:14:54 -0500 Subject: [PATCH] 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 --- src/xrpld/app/tx/detail/LoanSet.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/xrpld/app/tx/detail/LoanSet.cpp b/src/xrpld/app/tx/detail/LoanSet.cpp index 1da06851a5..e9eff856a6 100644 --- a/src/xrpld/app/tx/detail/LoanSet.cpp +++ b/src/xrpld/app/tx/detail/LoanSet.cpp @@ -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); }