ref: b488b851612ca5fa3c54f3b884281d93641293d9
parent: d48429529c894d2402edbf4bd718be316bea12c1
author: Sebastian Rasmussen <sebras@gmail.com>
date: Wed May 23 16:05:20 EDT 2018
jbig2dec: Avoid NULL-check before jbig2_free()/jbig2_image_release().
--- a/jbig2_halftone.c
+++ b/jbig2_halftone.c
@@ -103,8 +103,7 @@
if (dict == NULL)
return;
for (i = 0; i < dict->n_patterns; i++)
- if (dict->patterns[i])
- jbig2_image_release(ctx, dict->patterns[i]);
+ jbig2_image_release(ctx, dict->patterns[i]);
jbig2_free(ctx->allocator, dict->patterns);
jbig2_free(ctx->allocator, dict);
}
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -99,9 +99,7 @@
void
jbig2_huffman_free(Jbig2Ctx *ctx, Jbig2HuffmanState *hs)
{
- if (hs != NULL)
- jbig2_free(ctx->allocator, hs);
- return;
+ jbig2_free(ctx->allocator, hs);
}
/** debug routines **/
@@ -640,12 +638,8 @@
too_short:
jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "segment too short");
error_exit:
- if (line != NULL) {
- jbig2_free(ctx->allocator, line);
- }
- if (params != NULL) {
- jbig2_free(ctx->allocator, params);
- }
+ jbig2_free(ctx->allocator, line);
+ jbig2_free(ctx->allocator, params);
return -1;
}
@@ -654,8 +648,7 @@
jbig2_table_free(Jbig2Ctx *ctx, Jbig2HuffmanParams *params)
{
if (params != NULL) {
- if (params->lines != NULL)
- jbig2_free(ctx->allocator, (void *)params->lines);
+ jbig2_free(ctx->allocator, (void *)params->lines);
jbig2_free(ctx->allocator, params);
}
}
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -134,9 +134,8 @@
void
jbig2_free_segment(Jbig2Ctx *ctx, Jbig2Segment *segment)
{
- if (segment->referred_to_segments != NULL) {
- jbig2_free(ctx->allocator, segment->referred_to_segments);
- }
+ jbig2_free(ctx->allocator, segment->referred_to_segments);
+
/* todo: we need either some separate fields or
a more complex result object rather than this
brittle special casing */
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -126,8 +126,7 @@
if (dict == NULL)
return;
for (i = 0; i < dict->n_symbols; i++)
- if (dict->glyphs[i])
- jbig2_image_release(ctx, dict->glyphs[i]);
+ jbig2_image_release(ctx, dict->glyphs[i]);
jbig2_free(ctx->allocator, dict->glyphs);
jbig2_free(ctx->allocator, dict);
}