• Federico Mena Quintero's avatar
    gitlab#325 - rsvg_tree_free(): Cast the tree to our real Tree so it will get dropped · 2d3ddca1
    Federico Mena Quintero authored
    We had this:
    pub extern "C" fn rsvg_tree_free(tree: *mut RsvgTree) {
        if !tree.is_null() {
            let _ = unsafe { Box::from_raw(tree) };
                             ^ gets a Box<RsvgTree>, which is a box of a zero-sized enum
    I.e. it frees zero bytes :)
    With need this rebinding:
        let tree = unsafe { &mut *(tree as *mut Tree) };
    i.e. cast tree as *mut Tree, so we'll end up with a Box<Tree>
    which *can* be dropped as appropriate.
tree.rs 1.75 KB