mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #1252 from notmasteryet/issue-1249
Check if glyphs are stored outside the glyf table
This commit is contained in:
commit
d09c0fbfd3
4 changed files with 16 additions and 1 deletions
10
src/fonts.js
10
src/fonts.js
|
@ -1621,12 +1621,20 @@ var Font = (function FontClosure() {
|
|||
var locaData = loca.data;
|
||||
// removing the invalid glyphs
|
||||
var oldGlyfData = glyf.data;
|
||||
var newGlyfData = new Uint8Array(oldGlyfData.length);
|
||||
var oldGlyfDataLength = oldGlyfData.length;
|
||||
var newGlyfData = new Uint8Array(oldGlyfDataLength);
|
||||
var startOffset = itemDecode(locaData, 0);
|
||||
var writeOffset = 0;
|
||||
itemEncode(locaData, 0, writeOffset);
|
||||
for (var i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
|
||||
var endOffset = itemDecode(locaData, j);
|
||||
if (endOffset > oldGlyfDataLength) {
|
||||
// glyph end offset points outside glyf data, rejecting the glyph
|
||||
itemEncode(locaData, j, writeOffset);
|
||||
startOffset = endOffset;
|
||||
continue;
|
||||
}
|
||||
|
||||
var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset,
|
||||
newGlyfData, writeOffset);
|
||||
writeOffset += newLength;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue