diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-09-13 19:56:04 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-09-20 15:29:12 +0200 |
commit | 223403d2f7ba9c3cf6c727bdb81523bbe60a9179 (patch) | |
tree | 679206e89bd30daf723ffa06ba81bc79eb1ed034 | |
parent | e90d30ba31ad20b63ee207c062f6fdf43ea91669 (diff) | |
download | mupdf-223403d2f7ba9c3cf6c727bdb81523bbe60a9179.tar.xz |
Disable further device calls upon error while closing device.
-rw-r--r-- | source/fitz/device.c | 61 |
1 files changed, 34 insertions, 27 deletions
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 * |