From 1afde767c483e9672beed15c549717de2db061da Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Fri, 14 Apr 2023 11:47:57 +0000
Subject: [PATCH] print an error message if /Root not found

If we are actually processing page content, that is.
---
 pdf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/pdf.c b/pdf.c
index a7697b5..ae4efb7 100644
--- a/pdf.c
+++ b/pdf.c
@@ -4397,8 +4397,12 @@ process_page_content(struct Env *aux)
 
 	/* process the document starting from the /Root object */
 	tok = dictentry(trailer, "Root");
-	if (tok != NULL && tok->token_type == TT_Ref)
-		parse_catalog(aux, tok);
+	if (tok == NULL || tok->token_type != TT_Ref) {
+		log_message(5, "%s: missing or malformed /Root in trailer\n",
+		    aux->infile);
+		return;		// XXX return an error code!
+	}
+	parse_catalog(aux, tok);
 }
 
 
-- 
GitLab