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

Unified Diff: printing/pdf_metafile_cg_mac.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/pdf_metafile_cg_mac.h ('k') | printing/pdf_metafile_skia.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/pdf_metafile_cg_mac.cc
diff --git a/printing/pdf_metafile_cg_mac.cc b/printing/pdf_metafile_cg_mac.cc
index c9eb9df910b9cc51ae4451fa6d1b099cde080b12..16744bfde6c702ab27c3e3fa91df1cde8bd6148f 100644
--- a/printing/pdf_metafile_cg_mac.cc
+++ b/printing/pdf_metafile_cg_mac.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/sys_string_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
@@ -87,13 +88,15 @@ bool PdfMetafileCg::Init() {
}
bool PdfMetafileCg::InitFromData(const void* src_buffer,
- uint32_t src_buffer_size) {
+ size_t src_buffer_size) {
DCHECK(!context_.get());
DCHECK(!pdf_data_.get());
- if (!src_buffer || src_buffer_size == 0) {
+ if (!src_buffer || !src_buffer_size)
+ return false;
+
+ if (!base::IsValueInRangeForNumericType<CFIndex>(src_buffer_size))
return false;
- }
pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size));
CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer),
« no previous file with comments | « printing/pdf_metafile_cg_mac.h ('k') | printing/pdf_metafile_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698