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

Unified Diff: src/vorg.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/post.cc ('k') | src/woff2.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/vorg.cc
diff --git a/src/vorg.cc b/src/vorg.cc
index 61658fda61232434634c7a48d37187e808004026..b218c8895e4070bc5ce21e9c24df0fc1a3513eb8 100644
--- a/src/vorg.cc
+++ b/src/vorg.cc
@@ -71,15 +71,17 @@ bool ots_vorg_should_serialise(OpenTypeFile *file) {
bool ots_vorg_serialise(OTSStream *out, OpenTypeFile *file) {
OpenTypeVORG * const vorg = file->vorg;
-
- if (!out->WriteU16(vorg->major_version) ||
+
+ const uint16_t num_metrics = static_cast<uint16_t>(vorg->metrics.size());
+ if (num_metrics != vorg->metrics.size() ||
+ !out->WriteU16(vorg->major_version) ||
!out->WriteU16(vorg->minor_version) ||
!out->WriteS16(vorg->default_vert_origin_y) ||
- !out->WriteU16(vorg->metrics.size())) {
+ !out->WriteU16(num_metrics)) {
return OTS_FAILURE();
}
- for (unsigned i = 0; i < vorg->metrics.size(); ++i) {
+ for (uint16_t i = 0; i < num_metrics; ++i) {
const OpenTypeVORGMetrics& rec = vorg->metrics[i];
if (!out->WriteU16(rec.glyph_index) ||
!out->WriteS16(rec.vert_origin_y)) {
« no previous file with comments | « src/post.cc ('k') | src/woff2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698