Fix a potential overflow in SortedListBSearch
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 24 Jun 2014 09:37:51 +0000 (09:37 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 24 Jun 2014 09:37:51 +0000 (09:37 +0000)
R=yangguo@chromium.org

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

Patch from Jianghua Yang <jianghua.jhy@alibaba-inc.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21960 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/list-inl.h

index 8a4cf567040af7aca5534522f7ee11ece36920c9..fd1050ee3d1ac04a9958f5c1d09c17dfc5fc5991 100644 (file)
@@ -219,7 +219,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) {