Skip to content

extra::bigint does not handle overflow correctly #10522

@emberian

Description

@emberian

As an example,

extern mod extra;

use extra::bigint;
use extra::bigint::BigInt;
use extra::bigint::FromStr;
fn main() {
    let a:bigint::BigInt = FromStr::from_str("31").unwrap();
    let b:bigint::BigInt = FromStr::from_str("999999999999999999999999999999999999").unwrap();
    let c = (a+b).to_str();
    println(format!("{:?}",c));
}

will fail with

task '<main>' failed at 'vector size is too large: 18446744073709551615', /build/rust-git/src/rust/src/libstd/vec.rs:191

bigint needs to be carefully combed for overflow-correctness.

There is a test that makes sure this fails rather than segfaults in src/test/run-pass/bigint-overflow-segfault.rs that will need to be updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions