Commit b0f6a533 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Fix int-cast overflow in ScrollbarTheme

If we're at an offset that can't be represented at an int then the page
probably isn't usable but it's better to saturate than overflow here.

Bug: 1068200
Change-Id: I07afcf9b0486fac3311c0a128a1932b768b69d5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2137827
Auto-Submit: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757542}
parent f4090186
......@@ -191,7 +191,7 @@ int ScrollbarTheme::ThumbPosition(const Scrollbar& scrollbar,
return 0;
float pos = std::max(0.0f, scroll_position) *
(TrackLength(scrollbar) - ThumbLength(scrollbar)) / size;
return (pos < 1 && pos > 0) ? 1 : pos;
return (pos < 1 && pos > 0) ? 1 : base::saturated_cast<int>(pos);
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment