summaryrefslogtreecommitdiff
path: root/pdf/pdf_xref.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-06 14:57:56 +0000
committerRobin Watts <robin.watts@artifex.com>2012-01-06 14:57:56 +0000
commit95f29c10759bc42e940869f1a0d2f82db16f8709 (patch)
tree16c0563ee04f58ee8e6ec75ff09764230ca0ef14 /pdf/pdf_xref.c
parent6dd9108c5865c1ea2ab0e834f4ae85aa279bcca9 (diff)
downloadmupdf-95f29c10759bc42e940869f1a0d2f82db16f8709.tar.xz
PDF fixes/tweaks.
Fix 2 places where we were filling a stroked pattern rather than stroking it. Cope with being asked to run a NULL buffer. If running a stream fails, warn and return what we have, rather than giving up entirely. Should really set a return code for each render. Only look at the Print flag bit for Print renders. Only look at the View flag bit for view renders. If we find an unexpected ) or > during object parsing, warn and continue rather than giving up entirely. If optional content groups are broken, render the rest of the page anyway. Previously indirect objects that point to another indirection would cause a failure; now attempt to resolve these. We set an arbitrary limit of 10 such redirections to avoid infinite loops.
Diffstat (limited to 'pdf/pdf_xref.c')
-rw-r--r--pdf/pdf_xref.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index 55d7ce96..354620bb 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -769,8 +769,7 @@ pdf_open_xref_with_stream(fz_stream *file, char *password)
}
fz_catch(ctx)
{
- pdf_free_xref(xref);
- fz_throw(ctx, "Broken Optional Content");
+ fz_warn(ctx, "Ignoring Broken Optional Content");
}
return xref;
@@ -968,7 +967,11 @@ pdf_cache_object(pdf_xref *xref, int num, int gen)
}
if (rnum != num)
+ {
+ fz_drop_obj(x->obj);
+ x->obj = NULL;
fz_throw(ctx, "found object (%d %d R) instead of (%d %d R)", rnum, rgen, num, gen);
+ }
if (xref->crypt)
pdf_crypt_obj(ctx, xref->crypt, x->obj, num, gen);
@@ -1017,7 +1020,9 @@ pdf_load_object(pdf_xref *xref, int num, int gen)
fz_obj *
pdf_resolve_indirect(fz_obj *ref)
{
- if (fz_is_indirect(ref))
+ int sanity = 10;
+
+ while (fz_is_indirect(ref) && sanity--)
{
pdf_xref *xref = fz_get_indirect_xref(ref);
if (xref)
@@ -1034,8 +1039,9 @@ pdf_resolve_indirect(fz_obj *ref)
fz_warn(ctx, "cannot load object (%d %d R) into cache", num, gen);
return ref;
}
- if (xref->table[num].obj)
- return xref->table[num].obj;
+ if (!xref->table[num].obj)
+ return ref;
+ ref = xref->table[num].obj;
}
}
return ref;