ICU-8268 computation of average could overflow.
The (a+b)/2 or (a+b)>>1 could cause an overflow. Use unsigned bit shift (>>>). X-SVN-Rev: 30735
This commit is contained in:
parent
24f423c0f8
commit
6916271396
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2010, International Business Machines
|
||||
* Copyright (C) 2009-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -481,7 +481,7 @@ public final class BMPSet {
|
||||
// invariant: c >= list[lo]
|
||||
// invariant: c < list[hi]
|
||||
for (;;) {
|
||||
int i = (lo + hi) >> 1;
|
||||
int i = (lo + hi) >>> 1;
|
||||
if (i == lo) {
|
||||
break; // Found!
|
||||
} else if (c < list[i]) {
|
||||
|
@ -860,7 +860,7 @@ public final class ICUResourceBundleReader implements ICUBinary.Authenticate {
|
||||
start=0;
|
||||
limit=size;
|
||||
while(start<limit) {
|
||||
mid = (start + limit) / 2;
|
||||
mid = (start + limit) >>> 1;
|
||||
if (keyOffsets != null) {
|
||||
result = reader.compareKeys(key, keyOffsets[mid]);
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2009, International Business Machines
|
||||
* Copyright (C) 2001-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -984,7 +984,7 @@ final class BidiLine {
|
||||
|
||||
/* the middle if() is guaranteed to find the run, we don't need a loop limit */
|
||||
for ( ; ; ) {
|
||||
i = (begin + limit) / 2;
|
||||
i = (begin + limit) >>> 1;
|
||||
if (visualIndex >= runs[i].limit) {
|
||||
begin = i + 1;
|
||||
} else if (i==0 || visualIndex >= runs[i-1].limit) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -228,7 +228,7 @@ class BreakCTDictionary {
|
||||
int middle;
|
||||
node = null; // If we don't find a match, we'll fall out of the loop
|
||||
while (high >= low) {
|
||||
middle = (high + low) / 2;
|
||||
middle = (high + low) >>> 1;
|
||||
if (uc == hnode[middle].ch) {
|
||||
// We hit a match; get the next node and next character
|
||||
node = getCompactTrieNode(hnode[middle].equal);
|
||||
|
@ -529,7 +529,7 @@ final class NFRuleSet {
|
||||
int hi = rules.length;
|
||||
if (hi > 0) {
|
||||
while (lo < hi) {
|
||||
int mid = (lo + hi) / 2;
|
||||
int mid = (lo + hi) >>> 1;
|
||||
if (rules[mid].getBaseValue() == number) {
|
||||
return rules[mid];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user