summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/fitz/output-pnm.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c
index 496d8ea0..2b39899e 100644
--- a/source/fitz/output-pnm.c
+++ b/source/fitz/output-pnm.c
@@ -123,9 +123,15 @@ void
fz_write_pixmap_as_pnm(fz_context *ctx, fz_output *out, fz_pixmap *pixmap)
{
fz_band_writer *writer = fz_new_pnm_band_writer(ctx, out);
- fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace);
- fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples);
- fz_drop_band_writer(ctx, writer);
+ fz_try(ctx)
+ {
+ fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace);
+ fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples);
+ }
+ fz_always(ctx)
+ fz_drop_band_writer(ctx, writer);
+ fz_catch(ctx)
+ fz_rethrow(ctx);
}
void
@@ -220,9 +226,15 @@ void
fz_write_pixmap_as_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap)
{
fz_band_writer *writer = fz_new_pam_band_writer(ctx, out);
- fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace);
- fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples);
- fz_drop_band_writer(ctx, writer);
+ fz_try(ctx)
+ {
+ fz_write_header(ctx, writer, pixmap->w, pixmap->h, pixmap->n, pixmap->alpha, 0, 0, 0, pixmap->colorspace);
+ fz_write_band(ctx, writer, pixmap->stride, pixmap->h, pixmap->samples);
+ }
+ fz_always(ctx)
+ fz_drop_band_writer(ctx, writer);
+ fz_catch(ctx)
+ fz_rethrow(ctx);
}
void