diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-09-25 22:16:59 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-10-12 15:50:49 +0800 |
commit | ad9daf38f0f59a04fe5eebff286b5d3ffc8c9f1a (patch) | |
tree | dcfe0ab6add5ece010c01aab904d0c2b5dc19a08 | |
parent | cdea04525935533536f525c89770c807072be508 (diff) | |
download | mupdf-ad9daf38f0f59a04fe5eebff286b5d3ffc8c9f1a.tar.xz |
Drop xref subsection upon exception.
-rw-r--r-- | source/pdf/pdf-xref.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 2475b6e8..a792b7e2 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -339,11 +339,12 @@ static void ensure_incremental_xref(fz_context *ctx, pdf_document *doc) pdf_xref *xref = &doc->xref_sections[0]; pdf_xref *pxref; pdf_xref_entry *new_table = fz_calloc(ctx, xref->num_objects, sizeof(pdf_xref_entry)); - pdf_xref_subsec *sub; + pdf_xref_subsec *sub = NULL; pdf_obj *trailer = NULL; int i; fz_var(trailer); + fz_var(sub); fz_try(ctx) { sub = fz_malloc_struct(ctx, pdf_xref_subsec); @@ -354,19 +355,21 @@ static void ensure_incremental_xref(fz_context *ctx, pdf_document *doc) memmove(pxref, xref, doc->num_xref_sections * sizeof(pdf_xref)); /* xref->num_objects is already correct */ xref->subsec = sub; + sub = NULL; xref->trailer = trailer; xref->pre_repair_trailer = NULL; xref->unsaved_sigs = NULL; xref->unsaved_sigs_end = NULL; - sub->next = NULL; - sub->len = xref->num_objects; - sub->start = 0; - sub->table = new_table; + xref->subsec->next = NULL; + xref->subsec->len = xref->num_objects; + xref->subsec->start = 0; + xref->subsec->table = new_table; doc->num_xref_sections++; doc->num_incremental_sections++; } fz_catch(ctx) { + fz_free(ctx, sub); fz_free(ctx, new_table); pdf_drop_obj(ctx, trailer); fz_rethrow(ctx); |