From b8214e260cfafa896bbc132aff13b01d05850773 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Thu, 20 Oct 2011 13:18:52 +0000 Subject: [PATCH] WIP: remove memory leak about new jp2_read_marker function --- CHANGES | 1 + libopenjpeg/j2k.c | 1 + libopenjpeg/jp2.c | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGES b/CHANGES index 09d6ee51..98ba1377 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ What's New for OpenJPEG + : added October 20, 2011 +* [mickael] WIP: remove memory leak about new jp2_read_marker function * [mickael] WIP: remove previous commit about memory leak with ppm read function * [mickael] WIP: solve memory leak with ppm read function diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index e3e4c498..263713b7 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -7716,6 +7716,7 @@ opj_bool j2k_decode_tiles ( opj_j2k_v2_t *p_j2k, &l_go_on, p_stream, p_manager)) { + opj_free(l_current_data); return OPJ_FALSE; } diff --git a/libopenjpeg/jp2.c b/libopenjpeg/jp2.c index ed7c79f6..ee913140 100644 --- a/libopenjpeg/jp2.c +++ b/libopenjpeg/jp2.c @@ -2570,11 +2570,33 @@ void jp2_destroy(opj_jp2_v2_t *jp2) } if (jp2->color.jp2_cdef) { + if (jp2->color.jp2_cdef->info) { + opj_free(jp2->color.jp2_cdef->info); + jp2->color.jp2_cdef->info = NULL; + } + opj_free(jp2->color.jp2_cdef); jp2->color.jp2_cdef = 00; } if (jp2->color.jp2_pclr) { + if (jp2->color.jp2_pclr->cmap) { + opj_free(jp2->color.jp2_pclr->cmap); + jp2->color.jp2_pclr->cmap = NULL; + } + if (jp2->color.jp2_pclr->channel_sign) { + opj_free(jp2->color.jp2_pclr->channel_sign); + jp2->color.jp2_pclr->channel_sign = NULL; + } + if (jp2->color.jp2_pclr->channel_size) { + opj_free(jp2->color.jp2_pclr->channel_size); + jp2->color.jp2_pclr->channel_size = NULL; + } + if (jp2->color.jp2_pclr->entries) { + opj_free(jp2->color.jp2_pclr->entries); + jp2->color.jp2_pclr->entries = NULL; + } + opj_free(jp2->color.jp2_pclr); jp2->color.jp2_pclr = 00; }