Skip to content

Double free in mir will violate exception safety in this crate. #2

@cchanging

Description

@cchanging

We detected several double free bugs in your crate via static analysis.
Double free will appear when these function unwind, mainly caused by Vec::from_raw_parts & mem::forget.
In Rust Mir, inserting code between Vec::from_raw_parts & mem::forget will violate exception safety. Because when these code unwind, the Vec generated will drop as well as the entity which ptr pointed to.

let slots = unsafe { Vec::from_raw_parts(self.slots, self.nslots, self.capacity) };

mem::forget(slots);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions