mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
numfmt: prevent panic if float precision specifier > 65535 (#12600)
This commit is contained in:
@@ -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$}"))
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user