Skip to content

Replace ClearOnDrop with Zeroize #2

@burdges

Description

@burdges

The clear_on_drop crate is no longer maintained and uses fragile techniques. We expected it to break as linker optimizations work their way into rustc, etc. You should expose zeroing with the zeroize and if your dependencies do not yet support zeroing then you can implement the Zeroize trait using a function like

#[inline(always)]
fn zeroize_hack<Z: Default>(z: &mut Z) {
    use core::{ptr, sync::atomic};
    unsafe { ptr::write_volatile(z, Z::default()); }
    atomic::compiler_fence(atomic::Ordering::SeqCst);
}

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