diff options
Diffstat (limited to 'Build/source/texk/dvipdf-x/src/pdfobj.c')
-rw-r--r-- | Build/source/texk/dvipdf-x/src/pdfobj.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/Build/source/texk/dvipdf-x/src/pdfobj.c b/Build/source/texk/dvipdf-x/src/pdfobj.c index 55cc96912d9..9f87910f718 100644 --- a/Build/source/texk/dvipdf-x/src/pdfobj.c +++ b/Build/source/texk/dvipdf-x/src/pdfobj.c @@ -117,6 +117,7 @@ struct pdf_stream struct pdf_indirect { pdf_file *pf; + pdf_obj *obj; /* used when PF == NULL */ unsigned long label; unsigned short generation; }; @@ -193,6 +194,7 @@ static void release_objstm (pdf_obj *objstm); static void pdf_out_char (FILE *file, char c); static void pdf_out (FILE *file, const void *buffer, long length); +static pdf_obj *pdf_new_ref (pdf_obj *object); static void release_indirect (pdf_indirect *data); static void write_indirect (pdf_indirect *indirect, FILE *file); @@ -680,10 +682,7 @@ pdf_ref_obj (pdf_obj *object) if (PDF_OBJ_INDIRECTTYPE(object)) { return pdf_link_obj(object); } else { - if (object->label == 0) { - pdf_label_obj(object); - } - return pdf_new_indirect(NULL, object->label, object->generation); + return pdf_new_ref(object); } } @@ -2271,6 +2270,7 @@ pdf_new_indirect (pdf_file *pf, unsigned long obj_num, unsigned short obj_gen) indirect = NEW(1, pdf_indirect); indirect->pf = pf; + indirect->obj = NULL; indirect->label = obj_num; indirect->generation = obj_gen; @@ -2505,9 +2505,24 @@ pdf_get_object (pdf_file *pf, unsigned long obj_num, unsigned short obj_gen) } #define OBJ_FILE(o) (((pdf_indirect *)((o)->data))->pf) +#define OBJ_OBJ(o) (((pdf_indirect *)((o)->data))->obj) #define OBJ_NUM(o) (((pdf_indirect *)((o)->data))->label) #define OBJ_GEN(o) (((pdf_indirect *)((o)->data))->generation) +static pdf_obj * +pdf_new_ref (pdf_obj *object) +{ + pdf_obj *result; + + if (object->label == 0) { + pdf_label_obj(object); + } + result = pdf_new_indirect(NULL, object->label, object->generation); + OBJ_OBJ(result) = object; + return result; +} + + /* pdf_deref_obj always returns a link instead of the original */ /* It never return the null object, but the NULL pointer instead */ pdf_obj * @@ -2520,11 +2535,19 @@ pdf_deref_obj (pdf_obj *obj) while (PDF_OBJ_INDIRECTTYPE(obj) && --count) { pdf_file *pf = OBJ_FILE(obj); - unsigned long obj_num = OBJ_NUM(obj); - unsigned short obj_gen = OBJ_GEN(obj); - ASSERT(pf); - pdf_release_obj(obj); - obj = pdf_get_object(pf, obj_num, obj_gen); + if (pf) { + unsigned long obj_num = OBJ_NUM(obj); + unsigned short obj_gen = OBJ_GEN(obj); + pdf_release_obj(obj); + obj = pdf_get_object(pf, obj_num, obj_gen); + } else { + pdf_obj *next_obj = OBJ_OBJ(obj); + if (!next_obj) { + ERROR("Undefined object reference"); + } + pdf_release_obj(obj); + obj = pdf_link_obj(next_obj); + } } if (!count) |