Bug 690607 - memleak in jbig2_parse_text_region
Summary: memleak in jbig2_parse_text_region
Status: RESOLVED DUPLICATE of bug 690596
Alias: None
Product: jbig2dec
Classification: Unclassified
Component: Parsing (show other bugs)
Version: unspecified
Hardware: Macintosh MacOS X
: P4 normal
Assignee: Henry Stiles
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-06 20:01 UTC by Krzysztof Kowalczyk
Modified: 2011-11-29 04:26 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Kowalczyk 2009-07-06 20:01:45 UTC
ws = jbig2_word_stream_buf_new(ctx, segment_data + offset, segment->data_length
- offset); allocated in jbig2_parse_text_region is not always freed. The code
clears ws after passing it to jbig2_arith_new() apparently assuming it doesn't
need to be freed in this case, but jbig2_arith_new() doesn't take ownership of
this memory so it still needs to be freed. It's consistent with how other places
in the code deal with jbig2_word_stream_buf_new() and jbig2_arith_new().

This patch fixes it:


Index: jbig2_text.c
===================================================================
--- jbig2_text.c        (revision 1236)
+++ jbig2_text.c        (working copy)
@@ -686,7 +686,6 @@
        }
 
        as = jbig2_arith_new(ctx, ws);
-       ws = 0;
 
         params.IADT = jbig2_arith_int_ctx_new(ctx);
         params.IAFS = jbig2_arith_int_ctx_new(ctx);
@@ -733,8 +732,8 @@
        jbig2_arith_int_ctx_free(ctx, params.IARDX);
        jbig2_arith_int_ctx_free(ctx, params.IARDY);
        jbig2_free(ctx->allocator, as);
-       jbig2_word_stream_buf_free(ctx, ws);
     }
+    jbig2_word_stream_buf_free(ctx, ws);
 
     jbig2_free(ctx->allocator, dicts);
Comment 1 Henry Stiles 2011-11-29 04:26:02 UTC

*** This bug has been marked as a duplicate of bug 690596 ***