Reviewers: Benedikt Meurer, jochen (ooo),

Message:
refer to :
http://googleresearch.blogspot.de/2006/06/extra-extra-read-all-about-it-nearly.html

Description:
Fix a potential overflow of binary search

BUG=

Please review this at https://codereview.chromium.org/1314253006/

Base URL: [email protected]:v8/v8-git-mirror.git@master

Affected files (+2, -2 lines):
  M src/list-inl.h
  M src/objects-inl.h


Index: src/list-inl.h
diff --git a/src/list-inl.h b/src/list-inl.h
index 94ef14dbaedba2f1ef1f76f02ae2e563880d0219..5a247d5fd766da538c0cc433d3600bb27e9d4abe 100644
--- a/src/list-inl.h
+++ b/src/list-inl.h
@@ -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) {
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 5b3c38e1e2958326a9ecff327c2f7f7227430b88..85b9835417e1619c1321ab1d629154ebcbdc3bb1 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2784,7 +2784,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();



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to