diff options
-rw-r--r-- | fitz/base_error.c | 5 | ||||
-rw-r--r-- | fitz/fitz.h | 3 | ||||
-rw-r--r-- | pdf/pdf_font.c | 8 | ||||
-rw-r--r-- | pdf/pdf_function.c | 6 | ||||
-rw-r--r-- | pdf/pdf_image.c | 26 | ||||
-rw-r--r-- | pdf/pdf_interpret.c | 7 | ||||
-rw-r--r-- | pdf/pdf_parse.c | 14 | ||||
-rw-r--r-- | pdf/pdf_repair.c | 16 | ||||
-rw-r--r-- | pdf/pdf_shade.c | 10 | ||||
-rw-r--r-- | pdf/pdf_stream.c | 8 | ||||
-rw-r--r-- | pdf/pdf_xref.c | 16 |
11 files changed, 86 insertions, 33 deletions
diff --git a/fitz/base_error.c b/fitz/base_error.c index b844fb6a..bd6801eb 100644 --- a/fitz/base_error.c +++ b/fitz/base_error.c @@ -2,6 +2,11 @@ /* Warning context */ +void fz_var_imp(void *var) +{ + var = var; /* Do nothing */ +} + void fz_flush_warnings(fz_context *ctx) { if (ctx->warn->count > 1) diff --git a/fitz/fitz.h b/fitz/fitz.h index 70d14086..09c12c14 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -162,6 +162,9 @@ struct fz_error_context_s char message[256]; }; +void fz_var_imp(void *); +#define fz_var(var) fz_var_imp((void *)&(var)) + #define fz_try(ctx) \ if (fz_push_try(ctx->error), \ !setjmp(ctx->error->stack[ctx->error->top].buffer)) \ diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index 3a94527b..b33cbbc0 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -391,7 +391,7 @@ pdf_load_simple_font(pdf_xref *xref, fz_obj *dict) fz_obj *encoding; fz_obj *widths; unsigned short *etable = NULL; - pdf_font_desc * volatile fontdesc; + pdf_font_desc *fontdesc; FT_Face face; FT_CharMap cmap; int symbolic; @@ -405,6 +405,8 @@ pdf_load_simple_font(pdf_xref *xref, fz_obj *dict) int fterr; fz_context *ctx = xref->ctx; + fz_var(fontdesc); + basefont = fz_to_name(fz_dict_gets(dict, "BaseFont")); fontname = clean_font_name(basefont); @@ -696,7 +698,7 @@ load_cid_font(pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode { fz_obj *widths; fz_obj *descriptor; - pdf_font_desc * volatile fontdesc; + pdf_font_desc *fontdesc; FT_Face face; int kind; char collection[256]; @@ -706,6 +708,8 @@ load_cid_font(pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode int dw; fz_context *ctx = xref->ctx; + fz_var(fontdesc); + fz_try(ctx) { /* Get font name and CID collection */ diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index 3ef0d75f..82c29dfd 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -817,13 +817,15 @@ parse_code(pdf_function *func, fz_stream *stream, int *codeptr) static void load_postscript_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) { - fz_stream * volatile stream = NULL; + fz_stream *stream = NULL; int codeptr; char buf[64]; int tok; int len; fz_context *ctx = xref->ctx; + fz_var(stream); + fz_try(ctx) { stream = pdf_open_stream(xref, num, gen); @@ -1328,7 +1330,7 @@ pdf_function * pdf_load_function(pdf_xref *xref, fz_obj *dict) { fz_context *ctx = xref->ctx; - pdf_function * volatile func; + pdf_function *func; fz_obj *obj; int i; diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index b8785cf4..f8c4277c 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -28,25 +28,31 @@ pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey) static fz_pixmap * pdf_load_image_imp(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask) { - fz_stream * volatile stm = NULL; - fz_pixmap * volatile tile = NULL; + fz_stream *stm = NULL; + fz_pixmap *tile = NULL; fz_obj *obj, *res; int w, h, bpc, n; int imagemask; int interpolate; int indexed; - fz_colorspace * volatile colorspace = NULL; - fz_pixmap * volatile mask = NULL; /* explicit mask/softmask image */ + fz_colorspace *colorspace = NULL; + fz_pixmap *mask = NULL; /* explicit mask/softmask image */ int usecolorkey; int colorkey[FZ_MAX_COLORS * 2]; float decode[FZ_MAX_COLORS * 2]; int stride; - unsigned char * volatile samples = NULL; + unsigned char *samples = NULL; int i, len; fz_context *ctx = xref->ctx; + fz_var(stm); + fz_var(tile); + fz_var(colorspace); + fz_var(mask); + fz_var(samples); + fz_try(ctx) { /* special case for JPEG2000 images */ @@ -285,12 +291,15 @@ pdf_is_jpx_image(fz_context *ctx, fz_obj *dict) static fz_pixmap * pdf_load_jpx_image(pdf_xref *xref, fz_obj *dict) { - fz_buffer * volatile buf = NULL; - fz_colorspace * volatile colorspace = NULL; + fz_buffer *buf = NULL; + fz_colorspace *colorspace = NULL; fz_pixmap *img; fz_obj *obj; fz_context *ctx = xref->ctx; + fz_var(buf); + fz_var(colorspace); + buf = pdf_load_stream(xref, fz_to_num(dict), fz_to_gen(dict)); /* RJW: "cannot load jpx image data" */ @@ -307,7 +316,10 @@ pdf_load_jpx_image(pdf_xref *xref, fz_obj *dict) /* RJW: "cannot load jpx image" */ if (colorspace) + { fz_drop_colorspace(ctx, colorspace); + colorspace = NULL; + } fz_drop_buffer(ctx, buf); buf = NULL; diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 6d312724..b82b4297 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -2452,10 +2452,13 @@ pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents) { fz_context *ctx = csi->dev->ctx; int len = sizeof csi->xref->scratch; - char * volatile buf = NULL; - fz_stream * volatile file = NULL; + char *buf = NULL; + fz_stream * file = NULL; int save_in_text; + fz_var(buf); + fz_var(file); + fz_try(ctx) { buf = fz_malloc(ctx, len); /* we must be re-entrant for type3 fonts */ diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c index 6b7fdb12..7174c23a 100644 --- a/pdf/pdf_parse.c +++ b/pdf/pdf_parse.c @@ -302,14 +302,18 @@ end: fz_obj * pdf_parse_dict(pdf_xref *xref, fz_stream *file, char *buf, int cap) { - fz_obj * volatile dict = NULL; - fz_obj * volatile key = NULL; - fz_obj * volatile val = NULL; + fz_obj *dict = NULL; + fz_obj *key = NULL; + fz_obj *val = NULL; int tok; int len; int a, b; fz_context *ctx = file->ctx; + fz_var(dict); + fz_var(key); + fz_var(val); + dict = fz_new_dict(ctx, 8); fz_try(ctx) @@ -430,13 +434,15 @@ pdf_parse_ind_obj(pdf_xref *xref, fz_stream *file, char *buf, int cap, int *onum, int *ogen, int *ostmofs) { - fz_obj * volatile obj = NULL; + fz_obj *obj = NULL; int num = 0, gen = 0, stm_ofs; int tok; int len; int a, b; fz_context *ctx = file->ctx; + fz_var(obj); + tok = pdf_lex(file, buf, cap, &len); /* RJW: cannot parse indirect object (%d %d R)", num, gen */ if (tok != PDF_TOK_INT) diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 7930b5b5..bfa89751 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -192,12 +192,12 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) fz_obj *dict, *obj; fz_obj *length; - fz_obj * volatile encrypt = NULL; - fz_obj * volatile id = NULL; - fz_obj * volatile root = NULL; - fz_obj * volatile info = NULL; + fz_obj *encrypt = NULL; + fz_obj *id = NULL; + fz_obj *root = NULL; + fz_obj *info = NULL; - struct entry * volatile list = NULL; + struct entry *list = NULL; int listlen; int listcap; int maxnum = 0; @@ -211,6 +211,12 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) int i, n, c; fz_context *ctx = xref->ctx; + fz_var(encrypt); + fz_var(id); + fz_var(root); + fz_var(info); + fz_var(list); + fz_seek(xref->file, 0, 0); fz_try(ctx) diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c index b281542b..3803f77e 100644 --- a/pdf/pdf_shade.c +++ b/pdf/pdf_shade.c @@ -960,15 +960,19 @@ pdf_load_type7_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, static fz_shade * pdf_load_shading_dict(pdf_xref *xref, fz_obj *dict, fz_matrix transform) { - fz_shade * volatile shade = NULL; - pdf_function * volatile func[FZ_MAX_COLORS] = { NULL }; - fz_stream * volatile stream = NULL; + fz_shade *shade = NULL; + pdf_function *func[FZ_MAX_COLORS] = { NULL }; + fz_stream *stream = NULL; fz_obj *obj; int funcs; int type; int i; fz_context *ctx = xref->ctx; + fz_var(shade); + fz_var(func); + fz_var(stream); + fz_try(ctx) { shade = fz_malloc(ctx, sizeof(fz_shade)); diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c index 614f076a..0a38d20f 100644 --- a/pdf/pdf_stream.c +++ b/pdf/pdf_stream.c @@ -228,9 +228,11 @@ pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int len fz_stream * pdf_open_raw_stream(pdf_xref *xref, int num, int gen) { - pdf_xref_entry * volatile x; + pdf_xref_entry *x; fz_stream *stm; + fz_var(x); + if (num < 0 || num >= xref->len) fz_throw(xref->ctx, "object id out of range (%d %d R)", num, gen); @@ -341,7 +343,9 @@ pdf_load_stream(pdf_xref *xref, int num, int gen) fz_stream *stm; fz_obj *dict, *obj; int i, len, n; - fz_buffer * volatile buf; + fz_buffer *buf; + + fz_var(buf); stm = pdf_open_stream(xref, num, gen); /* RJW: "cannot open stream (%d %d R)", num, gen */ diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index d391e55c..b447dde6 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -297,7 +297,7 @@ static fz_obj * pdf_read_new_xref(pdf_xref *xref, char *buf, int cap) { fz_stream *stm; - fz_obj * volatile trailer = NULL; + fz_obj *trailer = NULL; fz_obj *index = NULL; fz_obj *obj = NULL; int num, gen, stm_ofs; @@ -305,6 +305,8 @@ pdf_read_new_xref(pdf_xref *xref, char *buf, int cap) int t; fz_context *ctx = xref->ctx; + fz_var(trailer); + fz_try(ctx) { trailer = pdf_parse_ind_obj(xref, xref->file, buf, cap, &num, &gen, &stm_ofs); @@ -579,9 +581,11 @@ pdf_read_ocg(pdf_xref *xref) { fz_obj *obj, *ocg; int len, i; - pdf_ocg_descriptor * volatile desc; + pdf_ocg_descriptor *desc; fz_context *ctx = xref->ctx; + fz_var(desc); + obj = fz_dict_gets(fz_dict_gets(xref->trailer, "Root"), "OCProperties"); if (obj == NULL) return; @@ -844,8 +848,8 @@ pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap) { fz_stream *stm; fz_obj *objstm; - int * volatile numbuf = NULL; - int * volatile ofsbuf = NULL; + int *numbuf = NULL; + int *ofsbuf = NULL; fz_obj *obj; int first; @@ -854,8 +858,8 @@ pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap) int tok; fz_context *ctx = xref->ctx; - //fz_var(numbuf); - //fz_var(ofsbuf); + fz_var(numbuf); + fz_var(ofsbuf); fz_try(ctx) { objstm = pdf_load_object(xref, num, gen); |