Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: include/core/SkTSearch.h

Issue 1362613002: Fix possible integer overflow in SkTSearch's midpoint calculation (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fix operator precedence Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTSearch.h
diff --git a/include/core/SkTSearch.h b/include/core/SkTSearch.h
index a4e4994ef378b2b14a39c1da2daa601c35677f71..549bcfd7c844ef7e0e51f616b634fe8833f21dbd 100644
--- a/include/core/SkTSearch.h
+++ b/include/core/SkTSearch.h
@@ -49,7 +49,7 @@ int SkTSearch(const T base[], int count, const K& key, size_t elemSize, LESS& le
int hi = count - 1;
while (lo < hi) {
- int mid = (hi + lo) >> 1;
+ int mid = lo + ((hi - lo) >> 1);
const T* elem = (const T*)((const char*)base + mid * elemSize);
if (less(*elem, key))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698