summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2015-06-04 13:17:47 +0100
committerRobin Watts <Robin.Watts@artifex.com>2015-06-05 08:04:48 -0700
commitc22548d0539d35beb7230bcf94121ef596f4345b (patch)
tree70d3cf9924301a6f8ed5b0788c469d3054508cce /source
parent88141af716349b4c1154676e70732813b17a8883 (diff)
downloadmupdf-c22548d0539d35beb7230bcf94121ef596f4345b.tar.xz
Fix mutool clean for FZ_LARGEFILE case.
We were allocating the ofs array as ints and then filling it with fz_off_t's.
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-object.c7
-rw-r--r--source/pdf/pdf-write.c16
2 files changed, 15 insertions, 8 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index c93a9d52..c17d982c 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -345,6 +345,13 @@ void pdf_set_int(fz_context *ctx, pdf_obj *obj, int i)
NUM(obj)->u.i = i;
}
+void pdf_set_int_offset(fz_context *ctx, pdf_obj *obj, fz_off_t i)
+{
+ if (obj < PDF_OBJ__LIMIT || obj->kind != PDF_INT)
+ return;
+ NUM(obj)->u.i = i;
+}
+
/* for use by pdf_crypt_obj_imp to decrypt AES string in place */
void pdf_set_str_len(fz_context *ctx, pdf_obj *obj, int newlen)
{
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 8660484d..991341ca 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -499,7 +499,7 @@ objects_dump(fz_context *ctx, pdf_document *doc, pdf_write_options *opts)
for (i=0; i < pdf_xref_len(ctx, doc); i++)
{
- fprintf(stderr, "Object %d use=%x offset=%d\n", i, opts->use_list[i], opts->ofs_list[i]);
+ fprintf(stderr, "Object %d use=%x offset=%d\n", i, opts->use_list[i], (int)opts->ofs_list[i]);
}
}
#endif
@@ -1438,10 +1438,10 @@ update_linearization_params(fz_context *ctx, pdf_document *doc, pdf_write_option
fz_off_t offset;
pdf_set_int(ctx, opts->linear_l, opts->file_len);
/* Primary hint stream offset (of object, not stream!) */
- pdf_set_int(ctx, opts->linear_h0, opts->ofs_list[pdf_xref_len(ctx, doc)-1]);
+ pdf_set_int_offset(ctx, opts->linear_h0, opts->ofs_list[pdf_xref_len(ctx, doc)-1]);
/* Primary hint stream length (of object, not stream!) */
offset = (opts->start == 1 ? opts->main_xref_offset : opts->ofs_list[1] + opts->hintstream_len);
- pdf_set_int(ctx, opts->linear_h1, offset - opts->ofs_list[pdf_xref_len(ctx, doc)-1]);
+ pdf_set_int_offset(ctx, opts->linear_h1, offset - opts->ofs_list[pdf_xref_len(ctx, doc)-1]);
/* Object number of first pages page object (the first object of page 0) */
pdf_set_int(ctx, opts->linear_o, opts->page_object_lists->page[0]->object[0]);
/* Offset of end of first page (first page is followed by primary
@@ -1449,13 +1449,13 @@ update_linearization_params(fz_context *ctx, pdf_document *doc, pdf_write_option
* primary hint stream counts as part of the first pages data, I think.
*/
offset = (opts->start == 1 ? opts->main_xref_offset : opts->ofs_list[1] + opts->hintstream_len);
- pdf_set_int(ctx, opts->linear_e, offset);
+ pdf_set_int_offset(ctx, opts->linear_e, offset);
/* Number of pages in document */
pdf_set_int(ctx, opts->linear_n, opts->page_count);
/* Offset of first entry in main xref table */
- pdf_set_int(ctx, opts->linear_t, opts->first_xref_entry_offset + opts->hintstream_len);
+ pdf_set_int_offset(ctx, opts->linear_t, opts->first_xref_entry_offset + opts->hintstream_len);
/* Offset of shared objects hint table in the primary hint stream */
- pdf_set_int(ctx, opts->hints_s, opts->hints_shared_offset);
+ pdf_set_int_offset(ctx, opts->hints_s, opts->hints_shared_offset);
/* Primary hint stream length */
pdf_set_int(ctx, opts->hints_length, opts->hintstream_len);
}
@@ -2402,7 +2402,7 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_options *op
for (j = 0; j < pop[0]->len; j++)
{
int o = pop[0]->object[j];
- int min, max;
+ fz_off_t min, max;
min = opts->ofs_list[o];
if (o == opts->start-1)
max = opts->main_xref_offset;
@@ -2664,7 +2664,7 @@ void pdf_write_document(fz_context *ctx, pdf_document *doc, char *filename, fz_w
* 1 to n access rather than 0..n-1, and add space for 2 new
* extra entries that may be required for linearization. */
opts.use_list = fz_malloc_array(ctx, pdf_xref_len(ctx, doc) + 3, sizeof(int));
- opts.ofs_list = fz_malloc_array(ctx, pdf_xref_len(ctx, doc) + 3, sizeof(int));
+ opts.ofs_list = fz_malloc_array(ctx, pdf_xref_len(ctx, doc) + 3, sizeof(fz_off_t));
opts.gen_list = fz_calloc(ctx, pdf_xref_len(ctx, doc) + 3, sizeof(int));
opts.renumber_map = fz_malloc_array(ctx, pdf_xref_len(ctx, doc) + 3, sizeof(int));
opts.rev_renumber_map = fz_malloc_array(ctx, pdf_xref_len(ctx, doc) + 3, sizeof(int));