From 3fe413e5838eaf9d8bc30a9a49f0d7707e84db35 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 23 Jan 2018 22:53:52 +0000 Subject: add dereference error --- include/nspdf/errors.h | 1 + src/xref.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/nspdf/errors.h b/include/nspdf/errors.h index 6591dbb..a557b9d 100644 --- a/include/nspdf/errors.h +++ b/include/nspdf/errors.h @@ -25,6 +25,7 @@ typedef enum { NSPDFERROR_NOTFOUND, /**< key not found */ NSPDFERROR_FORMAT, /**< objects do not cornform to expected format */ NSPDFERROR_INCOMPLETE, /**< operation was not completed */ + NSPDFERROR_REFERENCE, /**< unable to dereference object. */ } nspdferror; #endif diff --git a/src/xref.c b/src/xref.c index 7780bf2..6218fac 100644 --- a/src/xref.c +++ b/src/xref.c @@ -160,6 +160,11 @@ nspdf__xref_get_referenced(struct nspdf_doc *doc, struct cos_object **cobj_out) return NSPDFERROR_OK; } + if (doc == NULL) { + /* a reference with no document to dereference against */ + return NSPDFERROR_REFERENCE; + } + entry = doc->xref_table + cobj->u.reference->id; /* check if referenced object is in range and exists. return null object if -- cgit v1.2.3