not-fl3 / macroquad

Cross-platform game engine in Rust.
Apache License 2.0
3.27k stars 317 forks source link

tweens::linear is unsound #723

Open MaxVerevkin opened 4 months ago

MaxVerevkin commented 4 months ago

The following code segfaults:

struct Node {
    b: Box<u8>,
    c: Box<u8>,
}
impl scene::Node for Node {}
let node = scene::add_node(Node {
    b: Box::new(0),
    c: Box::new(0),
});
tweens::linear(
    node,
    |node| {
        dbg!(&node.b);
        dbg!(&node.c);
        todo!()
    },
    0.0,
    1.0,
    1.0,
);

The lens callback receives a mutable reference pointing to uninitialized memory, which is immediate UB.