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

Unified Diff: src/cff_type2_charstring.cc

Issue 512923003: Fix MSVC warnings about possible value truncation. (Closed) Base URL: https://chromium.googlesource.com/external/ots.git@master
Patch Set: Created 6 years, 4 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 | « src/cff.cc ('k') | src/cmap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cff_type2_charstring.cc
diff --git a/src/cff_type2_charstring.cc b/src/cff_type2_charstring.cc
index ddb9657981848b2ab2a36a24b52e9c228cbcc165..2817d8073db44f054a4915b32f9a124f1c4b72e7 100644
--- a/src/cff_type2_charstring.cc
+++ b/src/cff_type2_charstring.cc
@@ -730,12 +730,14 @@ bool ValidateType2CharStringIndex(
const std::vector<CFFIndex *> &local_subrs_per_font,
const CFFIndex *local_subrs,
Buffer* cff_table) {
- if (char_strings_index.offsets.size() == 0) {
+ const uint16_t num_offsets =
+ static_cast<uint16_t>(char_strings_index.offsets.size());
+ if (num_offsets != char_strings_index.offsets.size() || num_offsets == 0) {
return OTS_FAILURE(); // no charstring.
}
// For each glyph, validate the corresponding charstring.
- for (unsigned i = 1; i < char_strings_index.offsets.size(); ++i) {
+ for (uint16_t i = 1; i < num_offsets; ++i) {
// Prepare a Buffer object, |char_string|, which contains the charstring
// for the |i|-th glyph.
const size_t length =
@@ -751,7 +753,7 @@ bool ValidateType2CharStringIndex(
Buffer char_string(cff_table->buffer() + offset, length);
// Get a local subrs for the glyph.
- const unsigned glyph_index = i - 1; // index in the map is 0-origin.
+ const uint16_t glyph_index = i - 1; // index in the map is 0-origin.
const CFFIndex *local_subrs_to_use = NULL;
if (!SelectLocalSubr(fd_select,
local_subrs_per_font,
« no previous file with comments | « src/cff.cc ('k') | src/cmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698