diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-12 08:45:02 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-16 22:57:32 +0800 |
commit | f631dc0ebc7910d4ef1b6e41bc36b1bfaf101a50 (patch) | |
tree | 12ae655aa825215e3b7f65b2599398608a9a4571 | |
parent | 2d11d22616a22156d0b892ded9d911ca9b02930f (diff) | |
download | mupdf-f631dc0ebc7910d4ef1b6e41bc36b1bfaf101a50.tar.xz |
Handle error when reading OCGs.
-rw-r--r-- | source/pdf/pdf-layer.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/pdf/pdf-layer.c b/source/pdf/pdf-layer.c index db0b0c1d..b5b5b635 100644 --- a/source/pdf/pdf-layer.c +++ b/source/pdf/pdf-layer.c @@ -711,9 +711,12 @@ pdf_read_ocg(fz_context *ctx, pdf_document *doc) /* Not ever supposed to happen, but live with it. */ return; len = pdf_array_len(ctx, ocg); + + desc = fz_malloc_struct(ctx, pdf_ocg_descriptor); + desc->ocgs = NULL; + fz_try(ctx) { - desc = fz_malloc_struct(ctx, pdf_ocg_descriptor); desc->num_configs = num_configs; desc->len = len; desc->ocgs = fz_calloc(ctx, len, sizeof(*desc->ocgs)); @@ -728,8 +731,7 @@ pdf_read_ocg(fz_context *ctx, pdf_document *doc) } fz_catch(ctx) { - if (desc) - fz_free(ctx, desc->ocgs); + fz_free(ctx, desc->ocgs); fz_free(ctx, desc); fz_rethrow(ctx); } |