Search the whole checkpoint trace if offset overflows during initial exponential search. (#3662)
This commit is contained in:
@ -237,7 +237,7 @@ library Checkpoints {
|
|||||||
offset <<= 1;
|
offset <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 low = offset < length ? length - offset : 0;
|
uint256 low = 0 < offset && offset < length ? length - offset : 0;
|
||||||
uint256 high = length - (offset >> 1);
|
uint256 high = length - (offset >> 1);
|
||||||
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
|
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ library Checkpoints {
|
|||||||
offset <<= 1;
|
offset <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 low = offset < length ? length - offset : 0;
|
uint256 low = 0 < offset && offset < length ? length - offset : 0;
|
||||||
uint256 high = length - (offset >> 1);
|
uint256 high = length - (offset >> 1);
|
||||||
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
|
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ function upperLookupRecent(${opts.historyTypeName} storage self, ${opts.keyTypeN
|
|||||||
offset <<= 1;
|
offset <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 low = offset < length ? length - offset : 0;
|
uint256 low = 0 < offset && offset < length ? length - offset : 0;
|
||||||
uint256 high = length - (offset >> 1);
|
uint256 high = length - (offset >> 1);
|
||||||
uint256 pos = _upperBinaryLookup(self.${opts.checkpointFieldName}, key, low, high);
|
uint256 pos = _upperBinaryLookup(self.${opts.checkpointFieldName}, key, low, high);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user