Skip to content

attempt to add with overflow #139

@stepancheg

Description

@stepancheg

Probably related to #138.

Min repro:

#[cfg(test)]
mod tests {
    use rstar::RTree;

    #[test]
    fn test() {
        let mut rtree = RTree::new();

        rtree.insert([-1231069110, 165759396]);
        rtree.insert([781046969, 1474650861]);
        rtree.insert([2044084841, -178727451]);
        rtree.insert([477217386, 1765868819]);
        rtree.insert([1257259285, -1226428015]);
        rtree.insert([-1802029933, -488481506]);
        rtree.insert([-1786107855, 2050884187]);
    }
}

Integer overflow is on this line:

self.lower.component_wise(&self.upper, |x, y| (x + y) / two)

The fix is probably to write this as:

x + (y - x) / two

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions