From f0c8a4732e52479072004950a488c09a892c0d58 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Fri, 14 Apr 2023 11:45:23 +0000 Subject: [PATCH] correctly look for /Root in the last trailer section A mistake snuck into commit 76e546ce, taking the last element of the xrefs array as the "last" trailer section. But the array is filled in reverse order by following the chain of startxref and /Prev pointers, so the (logical) last/latest section is xrefs[0]. --- pdf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf.c b/pdf.c index b310178..a7697b5 100644 --- a/pdf.c +++ b/pdf.c @@ -4367,7 +4367,7 @@ process_page_content(struct Env *aux) /* find the last trailer dictionary */ if (aux->nxrefs == 0) return; - tok = aux->xrefs[aux->nxrefs - 1]; /* last xref section */ + tok = aux->xrefs[0]; /* first element is latest (reverse order) */ trailer = H_INDEX(Dict, tok, 1); /* fetch Size (a required field) from the trailer dictionary */ -- GitLab