From 70b839386af7a0fb089da07dc15f072a3cc79d86 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 2 Apr 2015 15:31:21 +0200 Subject: [PATCH] Ensure that the cmap position is within the bounds of the font file in |readCmapTable| --- src/core/fonts.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index 751183a93..a22e7a1bc 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3250,7 +3250,10 @@ var Font = (function FontClosure() { } } - if (!potentialTable) { + if (potentialTable) { + font.pos = start + potentialTable.offset; + } + if (!potentialTable || font.peekByte() === -1) { warn('Could not find a preferred cmap table.'); return { platformId: -1, @@ -3260,7 +3263,6 @@ var Font = (function FontClosure() { }; } - font.pos = start + potentialTable.offset; var format = font.getUint16(); var length = font.getUint16(); var language = font.getUint16();