Skip to content

Commit

Permalink
Merge pull request mozilla#2385 from yurydelendik/issue-2374
Browse files Browse the repository at this point in the history
Rejects post table if maxp numGlyph does not match
  • Loading branch information
brendandahl committed Nov 16, 2012
2 parents ae62170 + 0646d39 commit 9910699
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,7 @@ var Font = (function FontClosure() {
}
}

function readPostScriptTable(post, properties) {
function readPostScriptTable(post, properties, maxpNumGlyphs) {
var start = (font.start ? font.start : 0) + post.offset;
font.pos = start;

Expand All @@ -3198,6 +3198,10 @@ var Font = (function FontClosure() {
break;
case 0x00020000:
var numGlyphs = int16(font.getBytes(2));
if (numGlyphs != maxpNumGlyphs) {
valid = false;
break;
}
var glyphNameIndexes = [];
for (var i = 0; i < numGlyphs; ++i) {
var index = int16(font.getBytes(2));
Expand Down Expand Up @@ -3532,7 +3536,7 @@ var Font = (function FontClosure() {

// The 'post' table has glyphs names.
if (post) {
var valid = readPostScriptTable(post, properties);
var valid = readPostScriptTable(post, properties, numGlyphs);
if (!valid) {
tables.splice(tables.indexOf(post), 1);
post = null;
Expand Down
Loading

0 comments on commit 9910699

Please sign in to comment.