diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-24 16:37:42 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-06-27 21:27:14 +0800 |
commit | 29af19695090b95cb5dcb77274f7ce68526e74a3 (patch) | |
tree | b14255e752333ff483b7da6022e3a77654d26b92 /source/fitz/output-png.c | |
parent | fab177c9983802870798ffb9ecb4b37e7523b49d (diff) | |
download | mupdf-29af19695090b95cb5dcb77274f7ce68526e74a3.tar.xz |
When PS/PNG band writers throw, end the deflate streams if open.
Diffstat (limited to 'source/fitz/output-png.c')
-rw-r--r-- | source/fitz/output-png.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c index 4a325959..87c69428 100644 --- a/source/fitz/output-png.c +++ b/source/fitz/output-png.c @@ -79,6 +79,7 @@ typedef struct png_band_writer_s unsigned char *cdata; uLong usize, csize; z_stream stream; + int stream_ended; } png_band_writer; static void @@ -262,6 +263,7 @@ png_write_trailer(fz_context *ctx, fz_band_writer *writer_) unsigned char block[1]; int err; + writer->stream_ended = 1; err = deflateEnd(&writer->stream); if (err != Z_OK) fz_throw(ctx, FZ_ERROR_GENERIC, "compression error %d", err); @@ -274,6 +276,13 @@ png_drop_band_writer(fz_context *ctx, fz_band_writer *writer_) { png_band_writer *writer = (png_band_writer *)(void *)writer_; + if (!writer->stream_ended) + { + int err = deflateEnd(&writer->stream); + if (err != Z_OK) + fz_warn(ctx, "ignoring compression error %d", err); + } + fz_free(ctx, writer->cdata); fz_free(ctx, writer->udata); } |