diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2017-03-09 17:09:51 +0000 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2017-03-10 18:03:59 -0600 |
commit | ea00b61c7ccd14422bef33282e18fa8b4660fe74 (patch) | |
tree | 3c134043132814f0d20867be11c8d280450e5737 | |
parent | b346bd28080a86acec3029aeda39e10213d431a5 (diff) | |
download | mupdf-ea00b61c7ccd14422bef33282e18fa8b4660fe74.tar.xz |
Fix potential double frees in error cases.
fz_new_stream cleans up the passed in state if the allocation
fails, so don't free it in the caller too.
-rw-r--r-- | source/fitz/stream-open.c | 10 | ||||
-rw-r--r-- | source/fitz/stream-prog.c | 10 |
2 files changed, 2 insertions, 18 deletions
diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c index f999014b..d1d35cbb 100644 --- a/source/fitz/stream-open.c +++ b/source/fitz/stream-open.c @@ -112,15 +112,7 @@ fz_open_file_ptr(fz_context *ctx, FILE *file) fz_file_stream *state = fz_malloc_struct(ctx, fz_file_stream); state->file = file; - fz_try(ctx) - { - stm = fz_new_stream(ctx, state, next_file, close_file); - } - fz_catch(ctx) - { - fz_free(ctx, state); - fz_rethrow(ctx); - } + stm = fz_new_stream(ctx, state, next_file, close_file); stm->seek = seek_file; return stm; diff --git a/source/fitz/stream-prog.c b/source/fitz/stream-prog.c index 837c33e3..579c7c4f 100644 --- a/source/fitz/stream-prog.c +++ b/source/fitz/stream-prog.c @@ -122,15 +122,7 @@ fz_open_file_ptr_progressive(fz_context *ctx, FILE *file, int bps) state->length = fz_ftell(state->file); fz_fseek(state->file, 0, SEEK_SET); - fz_try(ctx) - { - stm = fz_new_stream(ctx, state, next_prog, close_prog); - } - fz_catch(ctx) - { - fz_free(ctx, state); - fz_rethrow(ctx); - } + stm = fz_new_stream(ctx, state, next_prog, close_prog); stm->seek = seek_prog; stm->meta = meta_prog; |