From e05cbf8d7d512840e943bb62875a104d46c37701 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sun, 19 Sep 2010 20:13:30 +0300 Subject: Reject fonts missing 'names' table Fonts should always have a names table, I suppose, so if not we should reject the font. Reported by Philipp Stephani. --- otfl-font-nms.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 1f37d16..938b6bd 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -257,7 +257,7 @@ local function font_fullinfo(filename, subfont, texmf) if trace_loading then logs.report("error: failed to open %s", filename) end - return nil + return end local m = fontloader.to_table(f) fontloader.close(f) @@ -284,6 +284,12 @@ local function font_fullinfo(filename, subfont, texmf) } end end + else + -- no names table, propably a broken font + if trace_loading then + logs.report("broken font rejected: %s", basefile) + end + return end t.fontname = m.fontname t.fullname = m.fullname @@ -345,6 +351,9 @@ local function load_font(filename, fontnames, newfontnames, texmf) if type(info) == "table" and #info > 1 then for i in next, info do local fullinfo = font_fullinfo(filename, i-1, texmf) + if not fullinfo then + return + end local index = newstatus[basefile].index[i] if newstatus[basefile].index[i] then index = newstatus[basefile].index[i] @@ -356,6 +365,9 @@ local function load_font(filename, fontnames, newfontnames, texmf) end else local fullinfo = font_fullinfo(filename, false, texmf) + if not fullinfo then + return + end local index if newstatus[basefile].index[1] then index = newstatus[basefile].index[1] -- cgit v1.2.3