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

Unified Diff: src/layout.cc

Issue 139563002: [OTS] Add support for the MATH table. (Closed) Base URL: https://chromium.googlesource.com/external/ots.git@master
Patch Set: More fixes. Created 6 years, 11 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/layout.h ('k') | src/math.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/layout.cc
diff --git a/src/layout.cc b/src/layout.cc
index 99d04b30291b9506d8ef8ddaf5fd08f5644d2bb4..06be21770d850c2ed8c9697c5986798633da3d7a 100644
--- a/src/layout.cc
+++ b/src/layout.cc
@@ -336,7 +336,8 @@ bool ParseClassDefFormat2(const uint8_t *data, size_t length,
}
bool ParseCoverageFormat1(const uint8_t *data, size_t length,
- const uint16_t num_glyphs) {
+ const uint16_t num_glyphs,
+ const uint16_t expected_num_glyphs) {
ots::Buffer subtable(data, length);
// Skip format field.
@@ -363,11 +364,17 @@ bool ParseCoverageFormat1(const uint8_t *data, size_t length,
}
}
+ if (expected_num_glyphs && expected_num_glyphs != glyph_count) {
+ OTS_WARNING("unexpected number of glyphs: %u", glyph_count);
+ return OTS_FAILURE();
+ }
+
return true;
}
bool ParseCoverageFormat2(const uint8_t *data, size_t length,
- const uint16_t num_glyphs) {
+ const uint16_t num_glyphs,
+ const uint16_t expected_num_glyphs) {
ots::Buffer subtable(data, length);
// Skip format field.
@@ -411,6 +418,12 @@ bool ParseCoverageFormat2(const uint8_t *data, size_t length,
last_start_coverage_index += end - start + 1;
}
+ if (expected_num_glyphs &&
+ expected_num_glyphs != last_start_coverage_index) {
+ OTS_WARNING("unexpected number of glyphs: %u", last_start_coverage_index);
+ return OTS_FAILURE();
+ }
+
return true;
}
@@ -1335,7 +1348,8 @@ bool ParseClassDefTable(const uint8_t *data, size_t length,
}
bool ParseCoverageTable(const uint8_t *data, size_t length,
- const uint16_t num_glyphs) {
+ const uint16_t num_glyphs,
+ const uint16_t expected_num_glyphs) {
Buffer subtable(data, length);
uint16_t format = 0;
@@ -1343,9 +1357,9 @@ bool ParseCoverageTable(const uint8_t *data, size_t length,
return OTS_FAILURE();
}
if (format == 1) {
- return ParseCoverageFormat1(data, length, num_glyphs);
+ return ParseCoverageFormat1(data, length, num_glyphs, expected_num_glyphs);
} else if (format == 2) {
- return ParseCoverageFormat2(data, length, num_glyphs);
+ return ParseCoverageFormat2(data, length, num_glyphs, expected_num_glyphs);
}
return OTS_FAILURE();
« no previous file with comments | « src/layout.h ('k') | src/math.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698