diff --git a/pdf.c b/pdf.c index c08221204c935b21c1ae6e8487b62ea0b740ea8d..897f54da094930f358801db2c37b2cff2c93bb7d 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;