summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-object.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-02-27 14:39:21 +0000
committerRobin Watts <robin.watts@artifex.com>2015-02-27 17:20:32 +0000
commit8ff8784def2fbf49a303a86259919ff143050c5f (patch)
tree0bef30f78a42529ff56c99172da0cb2b3b3c25d6 /source/pdf/pdf-object.c
parent060ae5d3483fb4f060ecbbf2d706c1159b760114 (diff)
downloadmupdf-8ff8784def2fbf49a303a86259919ff143050c5f.tar.xz
Bug 695853: Fix pdf clean operation with invalid refs in input file.
MuPDF (and other PDF readers) treat invalid references as 'null' objects. For instance, in the supplied file, object 239 is supposedly free, but a reference is made to it. When cleaning (or linearising) a file, we renumber objects; such illegal refs then end up pointing somewhere else. The workaround here is simply to spot the invalid refs during the mark phase, and to set the referencing to null.
Diffstat (limited to 'source/pdf/pdf-object.c')
-rw-r--r--source/pdf/pdf-object.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index d4b008fb..1a0b9abf 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -566,6 +566,13 @@ pdf_array_put(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *item)
}
void
+pdf_array_put_drop(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *item)
+{
+ pdf_array_put(ctx, obj, i, item);
+ pdf_drop_obj(ctx, item);
+}
+
+void
pdf_array_push(fz_context *ctx, pdf_obj *obj, pdf_obj *item)
{
RESOLVE(obj);
@@ -880,6 +887,25 @@ pdf_dict_get_val(fz_context *ctx, pdf_obj *obj, int i)
return obj->u.d.items[i].v;
}
+void
+pdf_dict_put_val_drop(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *new_obj)
+{
+ RESOLVE(obj);
+ if (!obj || obj->kind != PDF_DICT)
+ {
+ pdf_drop_obj(ctx, new_obj);
+ return;
+ }
+ if (i < 0 || i >= obj->u.d.len)
+ {
+ /* FIXME: Should probably extend the dict here */
+ pdf_drop_obj(ctx, new_obj);
+ return;
+ }
+ pdf_drop_obj(ctx, obj->u.d.items[i].v);
+ obj->u.d.items[i].v = new_obj;
+}
+
static int
pdf_dict_finds(fz_context *ctx, pdf_obj *obj, const char *key, int *location)
{