Report a memory leak when process JP2 image.
Posted: 2013-12-23T12:12:54-07:00
Magic, I found a small memory leak which is in the jp2.c
under the CORE_coders package
static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
{
….
//here defined a icc color profile
icc_profile=(jas_iccprof_t *) NULL;
//then made a copy of color profile which never get rid of.
if (cm_profile != (jas_cmprof_t *) NULL)
icc_profile=jas_iccprof_createfromcmprof(cm_profile);
if (icc_profile != (jas_iccprof_t *) NULL)
{
jas_stream_t
*icc_stream;
icc_stream=jas_stream_memopen(NULL,0);
if ((icc_stream != (jas_stream_t *) NULL) &&
(jas_iccprof_save(icc_profile,icc_stream) == 0) &&
(jas_stream_flush(icc_stream) == 0))
{
jas_stream_memobj_t
*blob;
//here the local variable name icc_profile which is same as outside of the block
//may need rename??
StringInfo
*icc_profile,
*profile;
....
}
}
/**
* my fix, clean up icc_profile
*/
if (icc_profile != (jas_iccprof_t *) NULL)
{
jas_iccprof_destroy(icc_profile);
}
…
}
under the CORE_coders package
static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
{
….
//here defined a icc color profile
icc_profile=(jas_iccprof_t *) NULL;
//then made a copy of color profile which never get rid of.
if (cm_profile != (jas_cmprof_t *) NULL)
icc_profile=jas_iccprof_createfromcmprof(cm_profile);
if (icc_profile != (jas_iccprof_t *) NULL)
{
jas_stream_t
*icc_stream;
icc_stream=jas_stream_memopen(NULL,0);
if ((icc_stream != (jas_stream_t *) NULL) &&
(jas_iccprof_save(icc_profile,icc_stream) == 0) &&
(jas_stream_flush(icc_stream) == 0))
{
jas_stream_memobj_t
*blob;
//here the local variable name icc_profile which is same as outside of the block
//may need rename??
StringInfo
*icc_profile,
*profile;
....
}
}
/**
* my fix, clean up icc_profile
*/
if (icc_profile != (jas_iccprof_t *) NULL)
{
jas_iccprof_destroy(icc_profile);
}
…
}