diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-12 00:53:31 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-28 21:21:47 +0800 |
commit | 08b24ce7759f388ce9059dea987ba99f1ec0288a (patch) | |
tree | e64ae57d81d2490aad54b18bf70871f3feb31013 | |
parent | 29af19695090b95cb5dcb77274f7ce68526e74a3 (diff) | |
download | mupdf-08b24ce7759f388ce9059dea987ba99f1ec0288a.tar.xz |
Always drop repaired dictionary in case of error.
-rw-r--r-- | source/pdf/pdf-repair.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c index e8413b06..91bbca1a 100644 --- a/source/pdf/pdf-repair.c +++ b/source/pdf/pdf-repair.c @@ -476,32 +476,38 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc) continue; } - obj = pdf_dict_get(ctx, dict, PDF_NAME_Encrypt); - if (obj) + fz_try(ctx) { - pdf_drop_obj(ctx, encrypt); - encrypt = pdf_keep_obj(ctx, obj); - } + obj = pdf_dict_get(ctx, dict, PDF_NAME_Encrypt); + if (obj) + { + pdf_drop_obj(ctx, encrypt); + encrypt = pdf_keep_obj(ctx, obj); + } - obj = pdf_dict_get(ctx, dict, PDF_NAME_ID); - if (obj && (!id || !encrypt || pdf_dict_get(ctx, dict, PDF_NAME_Encrypt))) - { - pdf_drop_obj(ctx, id); - id = pdf_keep_obj(ctx, obj); - } + obj = pdf_dict_get(ctx, dict, PDF_NAME_ID); + if (obj && (!id || !encrypt || pdf_dict_get(ctx, dict, PDF_NAME_Encrypt))) + { + pdf_drop_obj(ctx, id); + id = pdf_keep_obj(ctx, obj); + } - obj = pdf_dict_get(ctx, dict, PDF_NAME_Root); - if (obj) - add_root(ctx, obj, &roots, &num_roots, &max_roots); + obj = pdf_dict_get(ctx, dict, PDF_NAME_Root); + if (obj) + add_root(ctx, obj, &roots, &num_roots, &max_roots); - obj = pdf_dict_get(ctx, dict, PDF_NAME_Info); - if (obj) - { - pdf_drop_obj(ctx, info); - info = pdf_keep_obj(ctx, obj); + obj = pdf_dict_get(ctx, dict, PDF_NAME_Info); + if (obj) + { + pdf_drop_obj(ctx, info); + info = pdf_keep_obj(ctx, obj); + } } + fz_always(ctx) + pdf_drop_obj(ctx, dict); + fz_catch(ctx) + fz_rethrow(ctx); - pdf_drop_obj(ctx, dict); obj = NULL; } @@ -558,11 +564,17 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc) pdf_obj *old_obj = NULL; dict = pdf_load_object(ctx, doc, list[i].num); - length = pdf_new_int(ctx, doc, list[i].stm_len); - pdf_dict_get_put_drop(ctx, dict, PDF_NAME_Length, length, &old_obj); - if (old_obj) - orphan_object(ctx, doc, old_obj); - pdf_drop_obj(ctx, dict); + fz_try(ctx) + { + length = pdf_new_int(ctx, doc, list[i].stm_len); + pdf_dict_get_put_drop(ctx, dict, PDF_NAME_Length, length, &old_obj); + if (old_obj) + orphan_object(ctx, doc, old_obj); + } + fz_always(ctx) + pdf_drop_obj(ctx, dict); + fz_catch(ctx) + fz_rethrow(ctx); } } |