From ad9469c7f40b21a3c80ba3657a06d25ac7e5eb5f Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Tue, 21 Nov 2023 22:00:37 -0500 Subject: [PATCH] update mupdf --- mupdf/source/fitz/lzxd.c | 1 + mupdf/source/fitz/unchm.c | 14 +++++++++----- mupdf/source/html/html-layout.c | 2 +- mupdf/source/pdf/pdf-clean-file.c | 6 +++--- mupdf/source/pdf/pdf-colorspace.c | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mupdf/source/fitz/lzxd.c b/mupdf/source/fitz/lzxd.c index 7d17fa11dfe7..d1825f7df661 100644 --- a/mupdf/source/fitz/lzxd.c +++ b/mupdf/source/fitz/lzxd.c @@ -882,6 +882,7 @@ drop_block(fz_context *ctx, block_t *block) case kind_alignedoffset: drop_tree(ctx, block->kind.u.aligned_offset.main_tree); drop_tree(ctx, block->kind.u.aligned_offset.length_tree); + drop_tree(ctx, block->kind.u.aligned_offset.aligned_offset_tree); break; case kind_uncompressed: break; diff --git a/mupdf/source/fitz/unchm.c b/mupdf/source/fitz/unchm.c index 11860a53399c..f619e0b973af 100644 --- a/mupdf/source/fitz/unchm.c +++ b/mupdf/source/fitz/unchm.c @@ -105,7 +105,7 @@ next_chm(fz_context *ctx, fz_stream *stm, size_t required) fz_throw(ctx, FZ_ERROR_GENERIC, "Short read in CHM handling"); stm->pos += n; stm->rp = state->buffer; - stm->wp = stm->wp + left; + stm->wp = stm->rp + left; return *stm->rp++; } @@ -339,7 +339,7 @@ get_encint(fz_context *ctx, fz_stream *stm, uint32_t *left) { uint32_t v = 0; uint32_t w; - int n = 4; + int res, n = 4; do { @@ -347,9 +347,10 @@ get_encint(fz_context *ctx, fz_stream *stm, uint32_t *left) fz_throw(ctx, FZ_ERROR_GENERIC, "Overly long encoded int in CHM"); (*left) -= 1; - w = fz_read_byte(ctx, stm); - if (w == EOF) + res = fz_read_byte(ctx, stm); + if (res == EOF) fz_throw(ctx, FZ_ERROR_GENERIC, "EOF in encoded int in CHM"); + w = res; v = (v<<7) | (w & 127); } while (w & 128); @@ -395,7 +396,10 @@ read_listing_chunk(fz_context *ctx, fz_chm_archive *chm, uint32_t dir_chunk_size n = fz_read(ctx, stm, (uint8_t *)name, namelen); if (n < namelen) fz_throw(ctx, FZ_ERROR_GENERIC, "Truncated name in CHM"); - name[namelen] = 0; + if (namelen > 1 && name[namelen - 1] == '/') + name[namelen - 1] = 0; + else + name[namelen] = 0; left -= namelen; sec = get_encint(ctx, stm, &left); off = get_encint(ctx, stm, &left); diff --git a/mupdf/source/html/html-layout.c b/mupdf/source/html/html-layout.c index 503dbb2f2d11..854db221829e 100644 --- a/mupdf/source/html/html-layout.c +++ b/mupdf/source/html/html-layout.c @@ -1251,7 +1251,7 @@ static void layout_table(fz_context *ctx, layout_data *ld, fz_html_box *box, fz_ { squish_block(ctx, row); continue; /* still skipping */ - } + } } layout_table_row(ctx, ld, row, ncol, colw, spacing); diff --git a/mupdf/source/pdf/pdf-clean-file.c b/mupdf/source/pdf/pdf-clean-file.c index c7f4a477b99d..1a74e49b237e 100644 --- a/mupdf/source/pdf/pdf-clean-file.c +++ b/mupdf/source/pdf/pdf-clean-file.c @@ -411,7 +411,7 @@ static void pdf_rearrange_pages_imp(fz_context *ctx, pdf_document *doc, int coun fz_catch(ctx) { fz_rethrow(ctx); -} + } } void pdf_rearrange_pages(fz_context *ctx, pdf_document *doc, int count, int *new_page_list) @@ -469,10 +469,10 @@ void pdf_clean_file(fz_context *ctx, char *infile, char *outfile, char *password if (spage < epage) for (page = spage; page <= epage; ++page) - pages[len++] = page; + pages[len++] = page - 1; else for (page = spage; page >= epage; --page) - pages[len++] = page; + pages[len++] = page - 1; } argidx++; diff --git a/mupdf/source/pdf/pdf-colorspace.c b/mupdf/source/pdf/pdf-colorspace.c index 9394f0424e4b..26048b390661 100644 --- a/mupdf/source/pdf/pdf-colorspace.c +++ b/mupdf/source/pdf/pdf-colorspace.c @@ -367,7 +367,7 @@ pdf_load_colorspace_imp(fz_context *ctx, pdf_obj *obj, pdf_cycle_list *cycle_up) pdf_cycle_list cycle; if (pdf_cycle(ctx, &cycle, cycle_up, obj)) - fz_throw(ctx, FZ_ERROR_SYNTAX, "recursive colorspace"); + fz_throw(ctx, FZ_ERROR_SYNTAX, "recursive colorspace"); if (pdf_is_name(ctx, obj)) {