akubera / bigdecimal-rs

Arbitrary precision decimal crate for Rust
Other
275 stars 71 forks source link

subtract overflow on `fmt::Display` on `BigDecimal` #94

Closed austinabell closed 2 months ago

austinabell commented 1 year ago

when trying to print a decimal with a very large negative scale and abs value of the integer length overflow usize::MAX, the print will panic.

Repro:

    let a = BigDecimal::new(bigdecimal::num_bigint::BigInt::from(1), i64::MIN);
    println!("{:?}", a);

The line I'm inferring is the issue here is https://github.com/akubera/bigdecimal-rs/blob/272123eddc02aad5d1a331ded8eb6605ed2bea96/src/lib.rs#L1566 (could be wrong, didn't verify)

akubera commented 2 months ago

This was fixed in v0.4.3, and added to the test suite in the impl_fmt::test::fmt_boundaries test module

Thanks for the report; sorry for being quiet.