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

Unified Diff: device/hid/hid_connection_mac.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile fix Created 4 years 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: device/hid/hid_connection_mac.cc
diff --git a/device/hid/hid_connection_mac.cc b/device/hid/hid_connection_mac.cc
index cd62324e4a8b1bfe635aff86d468193692cf7135..4aa4a8f3c5bb565098edb2e7bf8e0c06c56fa3ca 100644
--- a/device/hid/hid_connection_mac.cc
+++ b/device/hid/hid_connection_mac.cc
@@ -136,12 +136,12 @@ void HidConnectionMac::InputReportCallback(void* context,
scoped_refptr<net::IOBufferWithSize> buffer;
if (connection->device_info()->has_report_id()) {
// report_id is already contained in report_bytes
- buffer = new net::IOBufferWithSize(
- base::CheckedNumeric<size_t>(report_length).ValueOrDie());
+ buffer =
+ new net::IOBufferWithSize(base::checked_cast<size_t>(report_length));
memcpy(buffer->data(), report_bytes, report_length);
} else {
- buffer = new net::IOBufferWithSize(
- (base::CheckedNumeric<size_t>(report_length) + 1).ValueOrDie());
+ buffer = new net::IOBufferWithSize(static_cast<size_t>(
+ (base::CheckedNumeric<size_t>(report_length) + 1).ValueOrDie()));
buffer->data()[0] = 0;
memcpy(buffer->data() + 1, report_bytes, report_length);
}
« no previous file with comments | « content/renderer/pepper/pepper_media_stream_track_host_base.cc ('k') | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698