Open themighty1 opened 1 year ago
currently tree depth is incorrectly calculated for power-of-two leaf count. it is +1 than what it should be.
pub fn tree_depth(leaves_count: usize) -> usize { 8 * core::mem::size_of::<usize>() - leaves_count.leading_zeros() as usize }
e.g. for leaves_count == 4 this will return 3, whereas it should be 2.
leaves_count == 4
3
2
This bug doesn't seem to open any exploitable vectors, it only causes to allocate memory for a non-existent layer. It is still a good idea to fix this.
currently tree depth is incorrectly calculated for power-of-two leaf count. it is +1 than what it should be.
e.g. for
leaves_count == 4
this will return3
, whereas it should be2
.This bug doesn't seem to open any exploitable vectors, it only causes to allocate memory for a non-existent layer. It is still a good idea to fix this.