From fdb6fa15d58142a9be3aa5e14471ef83df8caff4 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 8 Nov 2021 15:04:01 +0200 Subject: FontPack: Don't crash if a font file is missing --- src/fontpack.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fontpack.c b/src/fontpack.c index 40e4c96c..c12b2ddc 100644 --- a/src/fontpack.c +++ b/src/fontpack.c @@ -401,12 +401,14 @@ void handleIniKeyValue_FontPack_(void *context, const iString *table, const iStr if (!data) { data = collect_Block(readFile_FontPack_(d, cleanPath)); } - ff = new_FontFile(); - set_String(&ff->id, fontFileId); - ff->colIndex = colIndex; - load_FontFile_(ff, data); - pushBack_ObjectList(fonts_.files, ff); /* centralized ownership */ - iRelease(ff); + if (data) { + ff = new_FontFile(); + set_String(&ff->id, fontFileId); + ff->colIndex = colIndex; + load_FontFile_(ff, data); + pushBack_ObjectList(fonts_.files, ff); /* centralized ownership */ + iRelease(ff); + } } d->loadSpec->styles[i] = ref_Object(ff); delete_String(fontFileId); -- cgit v1.2.3