Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

panic on unwrap of empty string #196

Open
alexanderkjall opened this issue Aug 19, 2020 · 0 comments
Open

panic on unwrap of empty string #196

alexanderkjall opened this issue Aug 19, 2020 · 0 comments

Comments

@alexanderkjall
Copy link
Contributor

Hi

I did some fuzzing of a library that uses this library, and found this issue:

called `Result::unwrap()` on an `Err` value: NulError(0, [0])
thread 'tests::test_to_c_str' panicked at 'called `Result::unwrap()` on an `Err` value: NulError(0, [0])', src/lib.rs:65:29

It can be replicated with this unit test.

#[cfg(test)]
mod tests {
    use std::str;
    use ToCStr;

    #[test]
    fn test_to_c_str() {
        let null : Vec<u8> = vec![0];
        let null_str = str::from_utf8(&null).unwrap();

        null_str.to_c_str();
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant