summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/nspdf/errors.h1
-rw-r--r--src/xref.c5
2 files changed, 6 insertions, 0 deletions
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