Fix binary search when search value is in the last block, but not equal

to the start of the range. PR 49444.
This commit is contained in:
joerg 2015-01-29 20:05:56 +00:00
parent 490187770a
commit e9d4ea8b6a
1 changed files with 6 additions and 8 deletions

View File

@ -263,21 +263,19 @@ public:
pint_t base = n->hdr_base;
pint_t first = n->hdr_start;
pint_t len = n->hdr_entries;
while (len) {
pint_t next = first + ((len + 1) / 2) * 8;
for (pint_t len = n->hdr_entries; len > 1; ) {
pint_t next = first + (len / 2) * 8;
pint_t nextPC = base + (int32_t)get32(next);
if (nextPC == pc) {
first = next;
break;
}
if (nextPC < pc) {
len -= (len + 1) / 2;
first = next;
} else if (len == 1)
break;
else
len = (len + 1) / 2;
len -= (len / 2);
} else {
len /= 2;
}
}
fdeStart = base + (int32_t)get32(first + 4);
data_base = n->data_base;