mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 12:20:07 +00:00
Merge pull request #153 from r-barnes/richard/binary_fix
Make binary search overflow safe
This commit is contained in:
commit
4dc4abfc31
@ -4721,7 +4721,7 @@ static IterT VmaBinaryFindFirstNotLess(IterT beg, IterT end, const KeyT &key, co
|
||||
size_t down = 0, up = (end - beg);
|
||||
while(down < up)
|
||||
{
|
||||
const size_t mid = (down + up) / 2;
|
||||
const size_t mid = down + (up - down) / 2; // Overflow-safe midpoint calculation
|
||||
if(cmp(*(beg+mid), key))
|
||||
{
|
||||
down = mid + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user