Skip to content

DeferMut for Imp is unsound #2

Description

@zakarumych

This simple code produces undefined behavior without unsafe code involved.

use interior_mutability_pointer::Imp;

fn main() {
    let mut a = Imp::new(vec![1]);
    let mut b = a.clone();

    let x = &mut a[0];
    b.clear();
    b.shrink_to_fit();

    println!("{}", *x); // USE AFTER FREE
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions