summaryrefslogtreecommitdiff
path: root/jbig2dec
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2020-06-23 01:27:25 +0800
committerSebastian Rasmussen <sebras@gmail.com>2020-06-23 01:28:04 +0800
commite0c1b3c8162898eaa46640cae98be34642704e3c (patch)
tree112132923f031c0609e2dbf81120ae4c9ef1db09 /jbig2dec
parent554b67a6f3ba5e6c78b35f94ab3f57e96b1a3dee (diff)
downloadghostpdl-e0c1b3c8162898eaa46640cae98be34642704e3c.tar.gz
jbig2dec: Fix memory leak caused by failing to allocate arithmetic coding context.
Diffstat (limited to 'jbig2dec')
-rw-r--r--jbig2dec/jbig2_text.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/jbig2dec/jbig2_text.c b/jbig2dec/jbig2_text.c
index a0d4d9746..1501ae321 100644
--- a/jbig2dec/jbig2_text.c
+++ b/jbig2dec/jbig2_text.c
@@ -945,7 +945,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data
as = jbig2_arith_new(ctx, ws);
if (as == NULL) {
code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to allocate arithmetic coding context when handling text region image");
- goto cleanup2;
+ goto cleanup3;
}
if (!params.SBHUFF) {
@@ -963,7 +963,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data
params.IAIT = jbig2_arith_int_ctx_new(ctx);
if (params.IADT == NULL || params.IAFS == NULL || params.IADS == NULL || params.IAIT == NULL) {
code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to allocate text region image data");
- goto cleanup3;
+ goto cleanup4;
}
/* Table 31 */
@@ -978,7 +978,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data
if (params.IAID == NULL || params.IARI == NULL ||
params.IARDW == NULL || params.IARDH == NULL || params.IARDX == NULL || params.IARDY == NULL) {
code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to allocate text region image data");
- goto cleanup4;
+ goto cleanup5;
}
}
@@ -987,7 +987,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data
segment_data + offset, segment->data_length - offset, GR_stats, as, ws);
if (code < 0) {
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to decode text region image data");
- goto cleanup4;
+ goto cleanup5;
}
if ((segment->flags & 63) == 4) {
@@ -1002,7 +1002,7 @@ jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to add text region to page");
}
-cleanup4:
+cleanup5:
if (!params.SBHUFF) {
jbig2_arith_iaid_ctx_free(ctx, params.IAID);
jbig2_arith_int_ctx_free(ctx, params.IARI);
@@ -1012,13 +1012,15 @@ cleanup4:
jbig2_arith_int_ctx_free(ctx, params.IARDY);
}
-cleanup3:
+cleanup4:
if (!params.SBHUFF) {
jbig2_arith_int_ctx_free(ctx, params.IADT);
jbig2_arith_int_ctx_free(ctx, params.IAFS);
jbig2_arith_int_ctx_free(ctx, params.IADS);
jbig2_arith_int_ctx_free(ctx, params.IAIT);
}
+
+cleanup3:
jbig2_free(ctx->allocator, as);
jbig2_word_stream_buf_free(ctx, ws);