diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-09-22 13:44:45 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-09-22 13:52:41 +0100 |
commit | 1e03c06456d997435019fb3526fa2d4be7dbc6ec (patch) | |
tree | 6cbe8ea587af3682fd4340d802fcfcc538d6e106 /source/pdf/pdf-xref.c | |
parent | fdf71862fe929b4560e9f632d775c50313d6ef02 (diff) | |
download | mupdf-1e03c06456d997435019fb3526fa2d4be7dbc6ec.tar.xz |
Bug 697015: Avoid object references vanishing during repair.
A PDF repair can be triggered 'just in time', when we encounter
a problem in the file. The idea is that this can happen without
the enclosing code being aware of it.
Thus the enclosing code may be holding 'borrowed' references
(such as those returned by pdf_dict_get()) at the time when the
repair is triggered. We are therefore at pains to ensure that
the repair does not replace any objects that exist already, so
that the calling code will not have these references unexpectedly
invalidated.
The sole exception to this is when we replace the 'Length' fields
in stream dictionaries with the actual lengths. Bug 697015 shows
exactly this situation causing a reference to become invalid.
The solution implemented here is to add an 'orphan list' to the
document, where we put these (hopefully few, small) objects. These
orphans are kept around until the document is closed.
Diffstat (limited to 'source/pdf/pdf-xref.c')
-rw-r--r-- | source/pdf/pdf-xref.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 7d21775a..0cf20d4c 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -1620,6 +1620,12 @@ pdf_drop_document_imp(fz_context *ctx, pdf_document *doc) pdf_drop_resource_tables(ctx, doc); + for (i = 0; i < doc->orphans_count; i++) + { + pdf_drop_obj(ctx, doc->orphans[i]); + } + fz_free(ctx, doc->orphans); + fz_free(ctx, doc); } fz_always(ctx) |