Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Unified Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 2598383002: Fix integer overflow. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/widget/widget.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 3b848bc9ddb9aa899dc8eaf96f30a0a97998e5b1..04c5a949777ebd8fa706b78a3b1c60072f78f3ff 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -1094,7 +1094,13 @@ void DesktopWindowTreeHostX11::SetOpacity(float opacity) {
// X server opacity is in terms of 32 bit unsigned int space, and counts from
// the opposite direction.
// XChangeProperty() expects "cardinality" to be long.
- unsigned long cardinality = static_cast<int>(opacity * 255) * 0x1010101;
+
+ // Scale opacity to [0 .. 255] range.
+ unsigned long opacity_8bit =
+ static_cast<unsigned long>(opacity * 255.0f) & 0xFF;
+ // Use opacity value for all channels.
+ const unsigned long channel_multiplier = 0x1010101;
+ unsigned long cardinality = opacity_8bit * channel_multiplier;
if (cardinality == 0xffffffff) {
XDeleteProperty(xdisplay_, xwindow_,
« no previous file with comments | « no previous file | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698