Speykious / cve-rs

Blazingly 🔥 fast 🚀 memory vulnerabilities, written in 100% safe Rust. 🦀
Other
3.72k stars 94 forks source link

C++ PTSD (pls gib therapy money) #22

Closed p-yukusai closed 4 months ago

p-yukusai commented 4 months ago

I'm just starting coding a project in Rust to run away from the pains of C++ and you've just slapped me with the PTSD of 3 billion hours I've spent tracking down segfaults while compiling in gcc, I now require a Ferris plushie to sleep at night or I get nightmares of null pointers :(

Creative0708 commented 4 months ago

Hi! Very sorry about your nonstop debugging of gcc since 469229 BCE. You can get a free Ferris plush with our crate, though!

#[derive(Debug)]
struct FerrisPlush {
    comfiness: f64,
}

fn acquire_ferris_plushie() -> &'static FerrisPlush {
    use rand::Rng;
    if rand::thread_rng().gen::<f32>() < 0.01 {
        return cve_rs::null();
    }
    // leak the box, because why would you ever want to deallocate a ferris plushie?!?!
    Box::leak(Box::new(cve_rs::transmute::<f64, _>(f64::MAX)))
}

fn main() {
    println!("{:?}", acquire_ferris_plushie());
}