servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.31k stars 325 forks source link

Panicked at 'assertion failed: self.is_char_boundary(new_len)' #872

Open WIZeaz opened 11 months ago

WIZeaz commented 11 months ago

Hi, I'm using a fuzz tool to test this repo, and my fuzzer report a panic about char boundary. The repo version is 1.2.0.

use std::string::String;
use form_urlencoded::Serializer;
fn foo(){
    let s=String::from("é0");
    let mut serializer= Serializer::for_suffix(s, 1);
    let _ = serializer.clear();
}

this code snippet will cause a char boundary panic:

thread 'main' panicked at 'assertion failed: self.is_char_boundary(new_len)', /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc\library\alloc\src\string.rs:1279:13