summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-06-15 07:34:18 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-06-15 07:38:38 +0200
commit3bd125a5c844cbd215f2a769619b23e93788ff47 (patch)
tree3eee73220a2144d9f25fd74ca7798784d9af66fd
parentba744a4bce3ed03eefbf2b4746fa24e6d388d9ff (diff)
downloadluaotfload-3bd125a5c844cbd215f2a769619b23e93788ff47.tar.gz
[db] fix initialization behavior to prevent crash
Reported by @dohyunkim: https://github.com/lualatex/luaotfload/pull/364#issuecomment-226059150 Under certain circumstances, update_names() was invoked with an empty table instead of a correctly initialized one, breaking the assumptions of the db populating code. This commit also guards more strongly against this kind of oversight and tidies up the db constructor.
-rw-r--r--src/luaotfload-database.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 7495ff2..3688c3a 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -416,10 +416,8 @@ mtx-fonts has in names.tma:
local initialize_namedata = function (formats, created)
local now = os.date "%Y-%m-%d %H:%M:%S" --- i. e. "%F %T" on POSIX systems
return {
- --families = { },
status = { }, -- was: status; map abspath -> mapping
mappings = { }, -- TODO: check if still necessary after rewrite
- names = { },
files = { }, -- created later
meta = {
created = created or now,
@@ -526,7 +524,8 @@ load_names = function (dry_run, no_rebuild)
names_version, db_version)
if not fonts_reloaded then
logreport ("both", 0, "db", [[Force rebuild.]])
- data = update_names ({ }, true, false)
+ data = update_names (initialize_namedata (get_font_filter ()),
+ true, false)
if not data then
logreport ("both", 0, "db",
"Database creation unsuccessful.")
@@ -3193,7 +3192,7 @@ update_names = function (currentnames, force, dry_run)
if force then
currentnames = initialize_namedata (get_font_filter ())
else
- if not currentnames then
+ if not currentnames or not next (currentnames) then
currentnames = load_names (dry_run)
end
if currentnames.meta.version ~= names.version then
@@ -3553,7 +3552,7 @@ return {
fonts.definers = fonts.definers or { resolvers = { } }
names.blacklist = blacklist
- names.version = 2.8
+ names.version = 2.9
names.data = nil --- contains the loaded database
names.lookups = nil --- contains the lookup cache