Skip to content

Commit

Permalink
Fix interval midpoint calculation in vulkan (#46839)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46839

Interval midpoint calculations can overflow (integers). This fixes such an instance.

Test Plan: Standard test rig.

Reviewed By: drdarshan

Differential Revision: D24392545

fbshipit-source-id: 84c81802165bb8084e2d54c9f3755f39143a5b00
  • Loading branch information
r-barnes authored and facebook-github-bot committed Oct 28, 2020
1 parent 98b3da8 commit 179d2b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aten/src/ATen/native/vulkan/api/vk_mem_alloc.h
Expand Up @@ -4594,7 +4594,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;
Expand Down

0 comments on commit 179d2b2

Please sign in to comment.