You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the code in line uint32_t index = ( one_past_max_index+min_index ) / 2; // ?? overflow it seems possible to have an overflow because according to binary search algorithm there is possibility of having an overflow when using the formular m=(l+r)/2 instead of this formula m=l+(r-l)/2
source : https://medium.com/swlh/overflow-bug-in-binary-search-c4d4a824807a
Cursor*leaf_node_find(Table*table, uint32_tpage_num, uint32_tkey)
{
// code ....while (one_past_max_index!=min_index) {
uint32_tindex= ( one_past_max_index+min_index ) / 2; // ?? overflowuint32_tkey_at_index=*leaf_node_key(node, index);
if (key==key_at_index) {
// set the cursor to the current position before returning it cursor->cell_num=index;
returncursor;
}
// follow the normal binary search algorithm based// on where the condition fall to whether mid-1 of mid + 1if (key<key_at_index) {
one_past_max_index=index;
} else {
min_index=index+1;
}
}
}
or what do you think ?
The text was updated successfully, but these errors were encountered:
According to the code in line
uint32_t index = ( one_past_max_index+min_index ) / 2; // ?? overflow
it seems possible to have an overflow because according to binary search algorithm there is possibility of having an overflow when using the formularm=(l+r)/2
instead of this formulam=l+(r-l)/2
source : https://medium.com/swlh/overflow-bug-in-binary-search-c4d4a824807a
or what do you think ?
The text was updated successfully, but these errors were encountered: