Commit 275cd657 authored by jianghua.yjh's avatar jianghua.yjh Committed by Commit bot

Fix a potential overflow of binary search

BUG=

Review URL: https://codereview.chromium.org/1314253006

Cr-Commit-Position: refs/heads/master@{#30638}
parent 6f454aa1
......@@ -250,7 +250,7 @@ int SortedListBSearch(const List<T>& list, P cmp) {
int low = 0;
int high = list.length() - 1;
while (low <= high) {
int mid = (low + high) / 2;
int mid = low + (high - low) / 2;
T mid_elem = list[mid];
if (cmp(&mid_elem) > 0) {
......
......@@ -2793,7 +2793,7 @@ int BinarySearch(T* array, Name* name, int low, int high, int valid_entries,
DCHECK(low <= high);
while (low != high) {
int mid = (low + high) / 2;
int mid = low + (high - low) / 2;
Name* mid_name = array->GetSortedKey(mid);
uint32_t mid_hash = mid_name->Hash();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment