commit 9fa8720962d7328de09421f84457e5c677994fd8 parent be9cee8bac54617f696c52f40247eacf4b76a002 Author: Marc Stibane <marc@taler.net> Date: Sat, 22 Aug 2026 10:20:57 +0200 AI: clamp Diffstat:
| M | TalerCommon/Helper/CurrencySpecification.swift | | | 5 | ++++- |
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/TalerCommon/Helper/CurrencySpecification.swift b/TalerCommon/Helper/CurrencySpecification.swift @@ -322,7 +322,10 @@ public class CurrencyFormatter: NumberFormatter { formatter.currency = currency // formatter.setCode(to: EUR_4217) // formatter.setSymbol(to: "€") - formatter.setMinimumFractionDigits(specs.fractionalTrailingZeroDigits) + // clamp: specs comes from the exchange and is untrusted; an out-of-range or negative + // value here would make NumberFormatter try to render millions of fractional digits + let trailingZeroDigits = min(max(specs.fractionalTrailingZeroDigits, 0), 8) + formatter.setMinimumFractionDigits(trailingZeroDigits) return formatter }