From 223403d2f7ba9c3cf6c727bdb81523bbe60a9179 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Wed, 13 Sep 2017 19:56:04 +0200 Subject: Disable further device calls upon error while closing device. --- source/fitz/device.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/device.c b/source/fitz/device.c index 5d2b7d7e..8a4e3394 100644 --- a/source/fitz/device.c +++ b/source/fitz/device.c @@ -16,33 +16,40 @@ fz_close_device(fz_context *ctx, fz_device *dev) { if (dev == NULL) return; - if (dev->close_device) - dev->close_device(ctx, dev); - - /* Don't call more than once! */ - dev->close_device = NULL; - - /* And disable all further device calls. */ - dev->fill_path = NULL; - dev->stroke_path = NULL; - dev->clip_path = NULL; - dev->clip_stroke_path = NULL; - dev->fill_text = NULL; - dev->stroke_text = NULL; - dev->clip_text = NULL; - dev->clip_stroke_text = NULL; - dev->ignore_text = NULL; - dev->fill_shade = NULL; - dev->fill_image = NULL; - dev->fill_image_mask = NULL; - dev->clip_image_mask = NULL; - dev->pop_clip = NULL; - dev->begin_mask = NULL; - dev->end_mask = NULL; - dev->begin_group = NULL; - dev->end_group = NULL; - dev->begin_tile = NULL; - dev->end_tile = NULL; + + fz_try(ctx) + { + if (dev->close_device) + dev->close_device(ctx, dev); + } + fz_always(ctx) + { + dev->close_device = NULL; /* Don't call more than once! */ + + /* And disable all further device calls. */ + dev->fill_path = NULL; + dev->stroke_path = NULL; + dev->clip_path = NULL; + dev->clip_stroke_path = NULL; + dev->fill_text = NULL; + dev->stroke_text = NULL; + dev->clip_text = NULL; + dev->clip_stroke_text = NULL; + dev->ignore_text = NULL; + dev->fill_shade = NULL; + dev->fill_image = NULL; + dev->fill_image_mask = NULL; + dev->clip_image_mask = NULL; + dev->pop_clip = NULL; + dev->begin_mask = NULL; + dev->end_mask = NULL; + dev->begin_group = NULL; + dev->end_group = NULL; + dev->begin_tile = NULL; + dev->end_tile = NULL; + } + fz_catch(ctx) + fz_rethrow(ctx); } fz_device * -- cgit v1.2.3