From ad9d1219f2e63241746671bd1f213ddbb08fdc41 Mon Sep 17 00:00:00 2001 From: Pompolic <pompolic@special-circumstanc.es> Date: Mon, 14 Mar 2022 17:56:49 +0100 Subject: [PATCH] Cherry-pick bc7e7b Original message: commit bc7e7b248afa51a5b0b357822b63bdadffd2f489 Author: sumit.ray@baesystems.com <sumit.ray@baesystems.com> Date: Thu Mar 10 19:23:21 2022 -0500 Add a guard to avoid processing a failed parse in parse_objstm_obj ... file:ff64f1c1f7591c39c737f8c6b51ef28d7f87a6cd8651fd6b8580c4598a1db3fc --- pdf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pdf.c b/pdf.c index c082212..897f54d 100644 --- a/pdf.c +++ b/pdf.c @@ -3011,7 +3011,7 @@ parse_objstm_obj(struct Env *aux, size_t nr, size_t stm_nr, size_t idx) } if ((stm = ent->obj) == NULL) { - fprintf(stderr, "%s: error parsing object stream at position " + fprintf(stdout, "%s: error parsing object stream at position " "%zu (%#zx)\n", aux->infile, ent->n.offs, ent->n.offs); return NULL; } @@ -3028,11 +3028,15 @@ parse_objstm_obj(struct Env *aux, size_t nr, size_t stm_nr, size_t idx) stm = H_INDEX_TOKEN(stm, 1); // the first field is the stream dictionary if (stm->token_type == TT_HParseResult){ const HParseResult *res = H_CAST(HParseResult, stm); - stm = res->ast; - // Now get the index if the index is valid - const Objstm *ostm = H_CAST(Objstm, stm); - if ( (idx>=0) && (idx < ostm->numObjs)) { - stm = ostm->tok[idx].obj; + if (res) { + stm = res->ast; + // Now get the index if the index is valid + const Objstm *ostm = H_CAST(Objstm, stm); + if ( (idx>=0) && (idx < ostm->numObjs)) { + stm = ostm->tok[idx].obj; + } + else + return NULL; } else return NULL; -- GitLab