From: jianghua.yjh Date: Tue, 8 Sep 2015 14:50:27 +0000 (-0700) Subject: Fix a potential overflow of binary search X-Git-Tag: upstream/4.7.83~402 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=275cd657df645d9c6f2bb5c2ec7446fb84557edd;p=platform%2Fupstream%2Fv8.git Fix a potential overflow of binary search BUG= Review URL: https://codereview.chromium.org/1314253006 Cr-Commit-Position: refs/heads/master@{#30638} --- diff --git a/src/list-inl.h b/src/list-inl.h index 94ef14dba..5a247d5fd 100644 --- a/src/list-inl.h +++ b/src/list-inl.h @@ -250,7 +250,7 @@ int SortedListBSearch(const List& 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) { diff --git a/src/objects-inl.h b/src/objects-inl.h index ce8cfe745..42e8354fb 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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();