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

Unified Diff: ui/gfx/buffer_format_util.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile cleanup and fix Created 4 years, 1 month 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
Index: ui/gfx/buffer_format_util.cc
diff --git a/ui/gfx/buffer_format_util.cc b/ui/gfx/buffer_format_util.cc
index 931b36d7947ecb151335cf2d9b0d6a42e923f026..8804c7e24a70aef802236dd6fb4281d0ac6576aa 100644
--- a/ui/gfx/buffer_format_util.cc
+++ b/ui/gfx/buffer_format_util.cc
@@ -53,7 +53,7 @@ bool RowSizeForBufferFormatChecked(
checked_size += 3;
if (!checked_size.IsValid())
return false;
- *size_in_bytes = checked_size.ValueOrDie() & ~0x3;
+ *size_in_bytes = (checked_size & ~0x3).ValueOrDie();
return true;
case BufferFormat::RG_88:
case BufferFormat::BGR_565:
@@ -63,7 +63,7 @@ bool RowSizeForBufferFormatChecked(
checked_size += 3;
if (!checked_size.IsValid())
return false;
- *size_in_bytes = checked_size.ValueOrDie() & ~0x3;
+ *size_in_bytes = (checked_size & ~0x3).ValueOrDie();
return true;
case BufferFormat::BGRX_8888:
case BufferFormat::RGBX_8888:
@@ -72,7 +72,7 @@ bool RowSizeForBufferFormatChecked(
checked_size *= 4;
if (!checked_size.IsValid())
return false;
- *size_in_bytes = checked_size.ValueOrDie();
+ *size_in_bytes = (checked_size & ~0x3).ValueOrDie();
return true;
case BufferFormat::YVU_420:
DCHECK_EQ(0u, width % 2);

Powered by Google App Engine
This is Rietveld 408576698