Skip to content

Cursor position silently wraps around during write to Vec<u8> #36884

Closed
@ghost

Description

use std::io::{Cursor, Write};

fn main() {
    let v = vec![0];
    let mut c = Cursor::new(v);
    c.set_position(std::usize::MAX as u64 + 1);
    c.write(&[1]).unwrap();
    println!("{:?}", c.into_inner());
}

On 32-bit platform it currently prints: "[1]". It should fail or panic instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions