From 23ac569165b66403abfe72e89007675ceaa9bde0 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 11 Oct 2016 20:39:26 +0800 Subject: Avoid checking argument to fz_drop_*()/fz_free(). As fz_drop_*()/fz_free() all must handle NULL. --- source/fitz/colorspace.c | 6 ++---- source/fitz/filter-jbig2.c | 9 +++------ source/fitz/font.c | 6 ++---- source/fitz/halftone.c | 9 +++------ source/fitz/image.c | 4 +--- source/fitz/load-jxr.c | 6 ++---- source/fitz/pixmap.c | 6 ++---- source/fitz/shade.c | 3 +-- source/fitz/stream-open.c | 3 +-- 9 files changed, 17 insertions(+), 35 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index 84e9b36c..0842c7f1 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -1996,8 +1996,7 @@ static void free_indexed(fz_context *ctx, fz_colorspace *cs) { struct indexed *idx = cs->data; - if (idx->base) - fz_drop_colorspace(ctx, idx->base); + fz_drop_colorspace(ctx, idx->base); fz_free(ctx, idx->lookup); fz_free(ctx, idx); } @@ -2167,8 +2166,7 @@ void fz_fin_cached_color_converter(fz_context *ctx, fz_color_converter *cc_) for (i = 0; i < n; i++) { void *v = fz_hash_get_val(ctx, cc->hash, i); - if (v) - fz_free(ctx, v); + fz_free(ctx, v); } fz_drop_hash(ctx, cc->hash); fz_free(ctx, cc); diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c index de5379be..b0445ed9 100644 --- a/source/fitz/filter-jbig2.c +++ b/source/fitz/filter-jbig2.c @@ -37,8 +37,7 @@ close_jbig2d(fz_context *ctx, void *state_) { fz_jbig2d *state = state_; fz_free(ctx, state->output); - if (state->gctx) - fz_drop_jbig2_globals(ctx, state->gctx); + fz_drop_jbig2_globals(ctx, state->gctx); fz_drop_stream(ctx, state->chain); fz_free(ctx, state); } @@ -234,8 +233,7 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals) } fz_catch(ctx) { - if (state) - fz_drop_jbig2_globals(ctx, state->gctx); + fz_drop_jbig2_globals(ctx, globals); fz_free(ctx, state); fz_drop_stream(ctx, chain); fz_rethrow(ctx); @@ -278,8 +276,7 @@ close_jbig2d(fz_context *ctx, void *state_) fz_jbig2d *state = state_; if (state->page) jbig2_release_page(state->ctx, state->page); - if (state->gctx) - fz_drop_jbig2_globals(ctx, state->gctx); + fz_drop_jbig2_globals(ctx, state->gctx); jbig2_ctx_free(state->ctx); fz_drop_stream(ctx, state->chain); fz_free(ctx, state); diff --git a/source/fitz/font.c b/source/fitz/font.c index 346168e8..e3ae4d7d 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -101,8 +101,7 @@ free_resources(fz_context *ctx, fz_font *font) if (font->t3procs) { for (i = 0; i < 256; i++) - if (font->t3procs[i]) - fz_drop_buffer(ctx, font->t3procs[i]); + fz_drop_buffer(ctx, font->t3procs[i]); } fz_free(ctx, font->t3procs); font->t3procs = NULL; @@ -133,8 +132,7 @@ fz_drop_font(fz_context *ctx, fz_font *font) { free_resources(ctx, font); for (i = 0; i < 256; i++) - if (font->t3lists[i]) - fz_drop_display_list(ctx, font->t3lists[i]); + fz_drop_display_list(ctx, font->t3lists[i]); fz_free(ctx, font->t3procs); fz_free(ctx, font->t3lists); fz_free(ctx, font->t3widths); diff --git a/source/fitz/halftone.c b/source/fitz/halftone.c index 0bc1dc98..dd9bb58f 100644 --- a/source/fitz/halftone.c +++ b/source/fitz/halftone.c @@ -515,7 +515,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha unsigned char *ht_line = NULL; unsigned char *o, *p; int w, h, x, y, n, pstride, ostride, lcm, i; - fz_halftone *ht_orig = ht; + fz_halftone *ht_ = NULL; threshold_fn *thresh; if (!pix) @@ -542,9 +542,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha } if (ht == NULL) - { - ht = fz_default_halftone(ctx, n); - } + ht_ = ht = fz_default_halftone(ctx, n); /* Find the minimum length for the halftone line. This * is the LCM of the halftone lengths and 8. (We need a @@ -583,8 +581,7 @@ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_ha } fz_always(ctx) { - if (!ht_orig) - fz_drop_halftone(ctx, ht); + fz_drop_halftone(ctx, ht_); fz_free(ctx, ht_line); } fz_catch(ctx) diff --git a/source/fitz/image.c b/source/fitz/image.c index 3420067d..48420a81 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -357,10 +357,8 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image } fz_catch(ctx) { - if (tile) - fz_drop_pixmap(ctx, tile); + fz_drop_pixmap(ctx, tile); fz_free(ctx, samples); - fz_rethrow(ctx); } diff --git a/source/fitz/load-jxr.c b/source/fitz/load-jxr.c index 3742b49e..f3809e69 100644 --- a/source/fitz/load-jxr.c +++ b/source/fitz/load-jxr.c @@ -422,10 +422,8 @@ fz_load_jxr(fz_context *ctx, unsigned char *data, size_t size) } fz_always(ctx) { - if (info.samples) - fz_free(ctx, info.samples); - if (info.cspace) - fz_drop_colorspace(ctx, info.cspace); + fz_free(ctx, info.samples); + fz_drop_colorspace(ctx, info.cspace); } fz_catch(ctx) { diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index 6ebc4770..c5a8a8cc 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -17,8 +17,7 @@ fz_drop_pixmap_imp(fz_context *ctx, fz_storable *pix_) { fz_pixmap *pix = (fz_pixmap *)pix_; - if (pix->colorspace) - fz_drop_colorspace(ctx, pix->colorspace); + fz_drop_colorspace(ctx, pix->colorspace); if (pix->free_samples) fz_free(ctx, pix->samples); fz_free(ctx, pix); @@ -77,8 +76,7 @@ fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h } fz_catch(ctx) { - if (colorspace) - fz_drop_colorspace(ctx, colorspace); + fz_drop_colorspace(ctx, colorspace); fz_free(ctx, pix); fz_rethrow(ctx); } diff --git a/source/fitz/shade.c b/source/fitz/shade.c index b4f4b0c7..274d40f3 100644 --- a/source/fitz/shade.c +++ b/source/fitz/shade.c @@ -1056,8 +1056,7 @@ fz_drop_shade_imp(fz_context *ctx, fz_storable *shade_) { fz_shade *shade = (fz_shade *)shade_; - if (shade->colorspace) - fz_drop_colorspace(ctx, shade->colorspace); + fz_drop_colorspace(ctx, shade->colorspace); if (shade->type == FZ_FUNCTION_BASED) fz_free(ctx, shade->u.f.fn_vals); fz_drop_compressed_buffer(ctx, shade->buffer); diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c index 05cbc48a..cb80b4f3 100644 --- a/source/fitz/stream-open.c +++ b/source/fitz/stream-open.c @@ -191,8 +191,7 @@ static void seek_buffer(fz_context *ctx, fz_stream *stm, fz_off_t offset, int wh static void close_buffer(fz_context *ctx, void *state_) { fz_buffer *state = (fz_buffer *)state_; - if (state) - fz_drop_buffer(ctx, state); + fz_drop_buffer(ctx, state); } fz_stream * -- cgit v1.2.3