Skip to content

Commit cc7c2ed

Browse files
authored
Merge pull request #1857 from Explorer09/table-bsearch-overflow
Avoid binary search arithmetic overflow in Table.c
2 parents 9270bbc + 8f299ec commit cc7c2ed

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎Table.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void Table_buildTreeBranch(Table* this, int rowid, unsigned int level, in
9898
int l = 0;
9999
int r = vsize;
100100
while (l < r) {
101-
int c = (l + r) / 2;
101+
int c = l + (r - l) / 2;
102102
Row* row = (Row*)Vector_get(this->rows, c);
103103
int parent = row->isRoot ? 0 : Row_getGroupOrParent(row);
104104
if (parent < rowid) {

0 commit comments

Comments
 (0)