From 9ce4e0f32ac805e3fc937b9f1e81e415e03b6865 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Tue, 14 Mar 2023 11:14:08 +0000 Subject: [PATCH] only call parse_catalog if /Root entry is present and of expected type Fixes #42. NB: The code in parse_xrefs() assumed the presence of a /Root entry in the trailer dictionary. Such code arguably does not belong in that function, whose purpose is to obtain the xref data, not to process the document. But where ever it belongs, the assumption is incorrect, so this fixes the immediate issue in place. --- pdf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf.c b/pdf.c index fb8876b..6ed644c 100644 --- a/pdf.c +++ b/pdf.c @@ -4984,8 +4984,8 @@ parse_xrefs(struct Env *aux) // Process the trailer dictionary const HParsedToken *root = dictentry(trailer, "Root"); - assert(root->token_type == TT_Ref); - parse_catalog(aux, root); + if(root != NULL && root->token_type == TT_Ref) + parse_catalog(aux, root); return; } -- GitLab