Index: src/post.cc |
diff --git a/src/post.cc b/src/post.cc |
index f4a0b0def778ab17ffe9be46d608a747b5f33458..44c2c7ddbad2e1a78341d1ca363823223f626375 100644 |
--- a/src/post.cc |
+++ b/src/post.cc |
@@ -146,11 +146,14 @@ bool ots_post_serialise(OTSStream *out, OpenTypeFile *file) { |
return true; // v1.0 and v3.0 does not have glyph names. |
} |
- if (!out->WriteU16(post->glyph_name_index.size())) { |
+ const uint16_t num_indexes = |
+ static_cast<uint16_t>(post->glyph_name_index.size()); |
+ if (num_indexes != post->glyph_name_index.size() || |
+ !out->WriteU16(num_indexes)) { |
return OTS_FAILURE(); |
} |
- for (unsigned i = 0; i < post->glyph_name_index.size(); ++i) { |
+ for (uint16_t i = 0; i < num_indexes; ++i) { |
if (!out->WriteU16(post->glyph_name_index[i])) { |
return OTS_FAILURE(); |
} |
@@ -159,8 +162,9 @@ bool ots_post_serialise(OTSStream *out, OpenTypeFile *file) { |
// Now we just have to write out the strings in the correct order |
for (unsigned i = 0; i < post->names.size(); ++i) { |
const std::string& s = post->names[i]; |
- const uint8_t string_length = s.size(); |
- if (!out->Write(&string_length, 1)) { |
+ const uint8_t string_length = static_cast<uint8_t>(s.size()); |
+ if (string_length != s.size() || |
+ !out->Write(&string_length, 1)) { |
return OTS_FAILURE(); |
} |
// Some ttf fonts (e.g., frank.ttf on Windows Vista) have zero-length name. |