ref: de271483ae5bf0ee87b73b44d9d433d4ca6a920a
parent: f72323e48008adb89a21bf01770a9583f456ff36
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Mon Jan 3 19:34:16 EST 2005
Properly free the decoded page image array on context free. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@380 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2.c
+++ b/jbig2.c
@@ -352,14 +352,18 @@
int i;
jbig2_free(ca, ctx->buf);
- if (ctx->segments != NULL)
- {
- for (i = ctx->segment_index; i < ctx->n_segments; i++)
- jbig2_free_segment(ctx, ctx->segments[i]);
- jbig2_free(ca, ctx->segments);
- }
+ if (ctx->segments != NULL) {
+ for (i = ctx->segment_index; i < ctx->n_segments; i++)
+ jbig2_free_segment(ctx, ctx->segments[i]);
+ jbig2_free(ca, ctx->segments);
+ }
- /* todo: free pages */
+ if (ctx->pages != NULL) {
+ for (i = 0; i <= ctx->current_page; i++)
+ if (ctx->pages[i].image != NULL)
+ jbig2_image_release(ctx, ctx->pages[i].image);
+ jbig2_free(ca, ctx->pages);
+ }
jbig2_free(ca, ctx);
}