summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-05-02 20:59:14 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-05-02 20:59:18 +0200
commit4ab4495fbd7df630ad313b9a93a2950c644fbd64 (patch)
treeeb16d8458a882b1f3733f414d008fcb0de4740be /src
parent9deb7fdf2296191efffd3324bb4d77e3d2bb224f (diff)
downloadluaotfload-4ab4495fbd7df630ad313b9a93a2950c644fbd64.tar.gz
[letterspace] fix crash with fonts with missing glyphs
Fix issue #351 The letterspace node handler dereferences kern values of non-existant character information under some circumstances, causing Luatex to crash. To avoid this crash, check more thoroughly for the presence of the fields accessed. Discovered by @schlcht
Diffstat (limited to 'src')
-rw-r--r--src/luaotfload-letterspace.lua32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/luaotfload-letterspace.lua b/src/luaotfload-letterspace.lua
index 007fa51..bda56b2 100644
--- a/src/luaotfload-letterspace.lua
+++ b/src/luaotfload-letterspace.lua
@@ -411,11 +411,20 @@ kerncharacters = function (head)
if keeptogether and keeptogether(prev, start) then
-- keep 'm
elseif identifiers[lastfont] then
- local kerns = chardata[lastfont] and chardata[lastfont][prevchar].kerns
- local kern = kerns and kerns[lastchar] or 0
- krn = kern + quaddata[lastfont]*krn -- here
- insert_node_before(head,start,kern_injector(fillup,krn))
- done = true
+ local lastfontchars = chardata[lastfont]
+ if lastfontchars then
+ local prevchardata = lastfontchars[prevchar]
+ if not prevchardata then
+ --- font doesn’t contain the glyph
+ else
+ local kern = 0
+ local kerns = prevchardata.kerns
+ if kerns then kern = kerns[lastchar] end
+ krn = kern + quaddata[lastfont]*krn -- here
+ insert_node_before(head,start,kern_injector(fillup,krn))
+ done = true
+ end
+ end
end
else
krn = quaddata[lastfont]*krn -- here
@@ -477,10 +486,19 @@ kerncharacters = function (head)
and getid(prv) == glyph_code
and getfont(prv) == lastfont
then
+ local kern = 0
local prevchar = getchar(prv)
local lastchar = getchar(start)
- local kerns = chardata[lastfont] and chardata[lastfont][prevchar].kerns
- local kern = kerns and kerns[lastchar] or 0
+ local lastfontchars = chardata[lastfont]
+ if lastfontchars then
+ local prevchardata = lastfontchars[prevchar]
+ if not prevchardata then
+ --- font doesn’t contain the glyph
+ else
+ local kerns = prevchardata.kerns
+ if kerns then kern = kerns[lastchar] end
+ end
+ end
krn = kern + quaddata[lastfont]*krn -- here
else
krn = quaddata[lastfont]*krn -- here