Open
Description
This safe code creates a string containing invalid utf-8, which is undefined behavior:
use bumpalo::{Bump, collections::string::String};
use std::panic::AssertUnwindSafe;
fn main() {
let bump = Bump::new();
let mut s = String::new_in(&bump);
s.push_str("_få_b");
std::panic::catch_unwind(AssertUnwindSafe(|| {
s.retain(|c| {
if c == 'b' {
panic!();
}
c != '_'
});
}));
println!("{:?}", core::str::from_utf8(s.as_bytes()));
}
Err(Utf8Error { valid_up_to: 3, error_len: Some(1) })
Metadata
Metadata
Assignees
Labels
No labels
Activity