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

Unified Diff: printing/emf_win.cc

Issue 2458513003: Addressing C4267 warnings for printing. (Closed)
Patch Set: Rebase, IsValueInRangeForNumericType for CFIndex Created 4 years, 2 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 | « printing/emf_win.h ('k') | printing/emf_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/emf_win.cc
diff --git a/printing/emf_win.cc b/printing/emf_win.cc
index 8dde50351ce64c7b2d08a4ed3111179042fce79f..1bcc75d946f9b8d55e8df1639ac13f3779cf78a9 100644
--- a/printing/emf_win.cc
+++ b/printing/emf_win.cc
@@ -14,6 +14,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
+#include "base/numerics/safe_conversions.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
#include "base/win/scoped_select_object.h"
@@ -186,9 +187,12 @@ bool Emf::Init() {
return !!hdc_;
}
-bool Emf::InitFromData(const void* src_buffer, uint32_t src_buffer_size) {
+bool Emf::InitFromData(const void* src_buffer, size_t src_buffer_size) {
DCHECK(!emf_ && !hdc_);
- emf_ = SetEnhMetaFileBits(src_buffer_size,
+ if (!base::IsValueInRangeForNumericType<UINT>(src_buffer_size))
+ return false;
+
+ emf_ = SetEnhMetaFileBits(static_cast<UINT>(src_buffer_size),
reinterpret_cast<const BYTE*>(src_buffer));
return !!emf_;
}
« no previous file with comments | « printing/emf_win.h ('k') | printing/emf_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698