diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2011-10-04 20:10:13 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2011-10-04 20:10:13 +0100 |
commit | 0a31674b1e78930e86d4d7408082f564bc550cf7 (patch) | |
tree | eb570a3a79d3d4c51c1152a253dd35cf82e026ee | |
parent | 1cc3bf432a6d94e6f8411b55ee0f591d098f2062 (diff) | |
download | mupdf-0a31674b1e78930e86d4d7408082f564bc550cf7.tar.xz |
Establish 'break scope' within fz_try macro
It is vital that no one returns from within fz_try. As such it's often
necessary to jump out of an fz_try. This can mean using a label at the
end of the fz_try section to goto.
By introducing a "do { } while (0)" around the contents of the fz_try
we allow people to 'break' (or 'continue') to get out neatly.
-rw-r--r-- | fitz/fitz.h | 3 | ||||
-rw-r--r-- | pdf/pdf_image.c | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 83eade3b..da39b04d 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -164,9 +164,10 @@ struct fz_error_context_s #define fz_try(ctx) \ if (fz_push_try(ctx->error), \ !setjmp(ctx->error->stack[ctx->error->top].buffer)) \ - { + { do { #define fz_catch(ctx) \ + } while(0); \ ctx->error->stack[ctx->error->top].failed = 0; \ } \ else \ diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index 1eff510a..438f4cef 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -63,7 +63,7 @@ pdf_load_image_imp(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, i tile = mask; mask = NULL; } - goto end; + break; /* Out of fz_try */ } w = fz_to_int(fz_dict_getsa(dict, "Width", "W")); @@ -234,8 +234,6 @@ pdf_load_image_imp(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, i { fz_decode_tile(tile, decode); } -end: - {} } fz_catch(ctx) { |