rev 388 - trunk
[email protected] Mon, 3 Jan 2005 23:05:40 -0800 (PST)
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: giles
Date: 2005-01-03 23:05:39 -0800 (Mon, 03 Jan 2005)
New Revision: 388
Modified:
trunk/jbig2_text.c
Log:
Correct some memory leaks in text region decoding: properly free arith=20
and word stream state, and release refined glyph images after=20
compositing.
Modified: trunk/jbig2_text.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_text.c 2005-01-04 07:04:17 UTC (rev 387)
+++ trunk/jbig2_text.c 2005-01-04 07:05:39 UTC (rev 388)
@@ -108,6 +108,7 @@
bool first_symbol;
uint32_t index, max_id;
Jbig2Image *IB;
+ Jbig2WordStream *ws =3D NULL;
Jbig2ArithState *as =3D NULL;
Jbig2ArithIntCtx *IADT =3D NULL;
Jbig2ArithIntCtx *IAFS =3D NULL;
@@ -132,7 +133,7 @@
if (!params->SBHUFF) {
int SBSYMCODELEN;
=20
- Jbig2WordStream *ws =3D jbig2_word_stream_buf_new(ctx, data, siz=
e);
+ ws =3D jbig2_word_stream_buf_new(ctx, data, size);
as =3D jbig2_arith_new(ctx, ws);
IADT =3D jbig2_arith_int_ctx_new(ctx);
IAFS =3D jbig2_arith_int_ctx_new(ctx);
@@ -230,7 +231,7 @@
index =3D 0;
while (id >=3D dicts[index]->n_symbols)
id -=3D dicts[index++]->n_symbols;
- IB =3D dicts[index]->glyphs[id];
+ IB =3D jbig2_image_clone(ctx, dicts[index]->glyphs[id]);
}
if (params->SBREFINE) {
code =3D jbig2_arith_int_decode(IARI, as, &RI);
@@ -264,6 +265,8 @@
jbig2_decode_refinement_region(ctx, segment,
&rparams, as, image, GR_stats);
IB =3D image;
+
+ jbig2_image_release(ctx, IBO);
}
=20
/* (3c.vi) */
@@ -311,10 +314,27 @@
=20
/* (3c.xi) */
NINSTANCES++;
+
+ jbig2_image_release(ctx, IB);
}
/* end strip */
}
/* 6.4.5 (4) */
+
+ if (!params->SBHUFF) {
+ jbig2_arith_int_ctx_free(ctx, IADT);
+ jbig2_arith_int_ctx_free(ctx, IAFS);
+ jbig2_arith_int_ctx_free(ctx, IADS);
+ jbig2_arith_int_ctx_free(ctx, IAIT);
+ jbig2_arith_iaid_ctx_free(ctx, IAID);
+ jbig2_arith_int_ctx_free(ctx, IARI);
+ jbig2_arith_int_ctx_free(ctx, IARDW);
+ jbig2_arith_int_ctx_free(ctx, IARDH);
+ jbig2_arith_int_ctx_free(ctx, IARDX);
+ jbig2_arith_int_ctx_free(ctx, IARDY);
+ jbig2_free(ctx->allocator, as);
+ jbig2_word_stream_buf_free(ctx, ws);
+ }
=20
return 0;
}
@@ -451,6 +471,12 @@
segment_data + offset, segment->data_length - offset,
GR_stats);
=20
+ if (!params.SBHUFF && params.SBREFINE) {
+ jbig2_free(ctx->allocator, GR_stats);
+ }
+
+ jbig2_free(ctx->allocator, dicts);
+
/* todo: check errors */
=20
if ((segment->flags & 63) =3D=3D 4) {