numfmt: prevent panic if float precision specifier > 65535 (#12600)

This commit is contained in:
Devel
2026-06-04 17:03:36 +02:00
committed by GitHub
parent d296f8d39f
commit bd9f32f7ae
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -628,7 +628,7 @@ fn transform_to(
"{:.precision$}",
round_with_precision(i2, round_method, precision),
)),
None if is_precision_specified => {
None if is_precision_specified && precision <= u16::MAX.into() => {
let i2 = round_with_precision(i2, round_method, 0);
localize(format!("{i2:.precision$}"))
}
+8
View File
@@ -1627,3 +1627,11 @@ fn test_multibyte_suffix_issue11937() {
.succeeds()
.stdout_is(" 692.00€\n");
}
#[test]
fn test_float_precision_greater_than_16bits() {
new_ucmd!()
.args(&["--to=iec", "--format=%.65536f", "1"])
.succeeds()
.stdout_is("1\n");
}