From dee6c4151d39813521feae83c44fc283bcb1ad8c Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Wed, 1 Mar 2023 14:00:14 +0000 Subject: [PATCH] avoid an assert in parse_fonts This is an assertion of the type that catches an error (in user-supplied data) that should be handled, namely the case where the /Font entry of a dictionary is expected to be itself a dictionary but isn't. The code already contains a path for the case where the /Font entry is missing (return false) and I suppose the same, including the TODO item "figure out how to handle", might as well apply instead of the assertion. Fixes #45. --- pdf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pdf.c b/pdf.c index 8841d3f..d1738ee 100644 --- a/pdf.c +++ b/pdf.c @@ -3743,8 +3743,9 @@ bool parse_fonts(const HParsedToken *dict_t, RsrcDict_T *pgRsrc, struct Env *aux // Handle a dictionary of font resources item = dictentry(fontdict, "Font"); item = resolve(aux, item); - if (item) { // TODO: Failure ==> xref error -- Figure out how to handle - assert(item->token_type == TT_Dict); + + if (item && item->token_type == TT_Dict) { + // XXX: Failure ==> xref error -- Figure out how to handle processed = true; Dict *fontlist = H_CAST(Dict, item); if (pgRsrc->fonts) { -- GitLab