Bug 690605

Summary: Fix memleak in jbig2 processing
Product: MuPDF Reporter: Krzysztof Kowalczyk <kkowalczyk>
Component: mupdfAssignee: Tor Andersson <tor.andersson>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: unspecified   
Hardware: Macintosh   
OS: MacOS X   
Customer: Word Size: ---

Description Krzysztof Kowalczyk 2009-07-06 19:37:32 UTC
A recent change added creating global jbig2 context when processing some jbig2
images, but didn't add code to free it, creating a leak. This patch fixes it:

Index: fitz/filt_jbig2d.c
===================================================================
--- fitz/filt_jbig2d.c  (revision 1236)
+++ fitz/filt_jbig2d.c  (working copy)
@@ -46,6 +46,7 @@
 {
        FZ_NEWFILTER(fz_jbig2d, d, jbig2d);
        d->ctx = jbig2_ctx_new(nil, JBIG2_OPTIONS_EMBEDDED, nil, nil, nil);
+       d->gctx = nil;
        d->page = nil;
        d->idx = 0;
        return fz_okay;
@@ -56,6 +57,8 @@
 {
        fz_jbig2d *d = (fz_jbig2d*)filter;
        jbig2_ctx_free(d->ctx);
+       if (d->gctx)
+               jbig2_global_ctx_free(d->gctx);
 }