summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Reinhardt <simon.reinhardt@stud.uni-regensburg.de>2015-10-10 09:06:25 +0200
committerTor Andersson <tor.andersson@artifex.com>2015-10-14 13:40:25 +0200
commit6bfb34fc98dfec2e5cb24888a240cfd651dc511b (patch)
tree2e392978b951ab549fb50e0267b6840df83d15d1
parentfa69ea8c236d5f58d6b158928a94ef527aa23457 (diff)
downloadmupdf-6bfb34fc98dfec2e5cb24888a240cfd651dc511b.tar.xz
Fix incremental xref stream.
When writing incremental xref streams, the opts->use_list entry of the last object, i.e. of the xref stream object itself, was left uninitialized. This resulted in a random value, 0 or 1, being written into the xref stream. Also, always write a newline before the endstream keyword, as that shall be done for xref streams and should be done for all other streams.
-rw-r--r--source/pdf/pdf-write.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 93560e81..310df6c1 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -1625,7 +1625,7 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_options *op
pdf_fprint_obj(ctx, opts->out, obj, opts->do_tight);
fputs("stream\n", opts->out);
fwrite(buf->data, 1, buf->len, opts->out);
- fputs("endstream\nendobj\n\n", opts->out);
+ fputs("\nendstream\nendobj\n\n", opts->out);
fz_drop_buffer(ctx, buf);
pdf_drop_obj(ctx, obj);
@@ -1674,7 +1674,7 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_options *
pdf_fprint_obj(ctx, opts->out, obj, opts->do_tight);
fputs("stream\n", opts->out);
fwrite(buf->data, 1, buf->len, opts->out);
- fputs("endstream\nendobj\n\n", opts->out);
+ fputs("\nendstream\nendobj\n\n", opts->out);
fz_drop_buffer(ctx, buf);
pdf_drop_obj(ctx, obj);
@@ -2020,9 +2020,11 @@ static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_option
index = pdf_new_array(ctx, doc, 2);
pdf_dict_put_drop(ctx, dict, PDF_NAME_Index, index);
+ /* opts->gen_list[num] is already initialized by fz_calloc. */
+ opts->use_list[num] = 1;
opts->ofs_list[num] = opts->first_xref_entry_offset;
- fzbuf = fz_new_buffer(ctx, 4*(to-from));
+ fzbuf = fz_new_buffer(ctx, (1 + 4 + 1) * (to-from));
if (opts->do_incremental)
{