Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am using the latest version of ImageMagick
- I have searched open and closed issues to ensure it has not already been reported
Description
hello,i find a memory leak bug in imagemagick,the details is on the Steps to Reproduce.
Steps to Reproduce
the bug located in meta.c ,static ssize_t parse8BIM(Image *ifile, Image *ofile) function
the bug code is on
https://github.com/ImageMagick/ImageMagick/blob/master/coders/meta.c#L327
the code fragment is as follows:
line = (char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*line)); //llocate a memory and assigned it to line
if (line == (char *) NULL)
return(-1);
newstr = name = token = (char *) NULL;
savedpos = 0;
token_info=AcquireTokenInfo();
we can see that we allocate a memory and assigned it to line,but we forget to free it in the code:
https://github.com/ImageMagick/ImageMagick/blob/master/coders/meta.c#L436
the code is as follows:
if (savedolen > 0)
{
MagickOffsetType
offset;
ssize_t diff = outputlen - savedolen;
currentpos = TellBlob(ofile);
if (currentpos < 0)
return(-1); // return without free line pointed memory
offset=SeekBlob(ofile,savedpos,SEEK_SET);
if (offset < 0)
return(-1); // return without free line pointed memory
(void) WriteBlobMSBLong(ofile,(unsigned int) diff);
offset=SeekBlob(ofile,currentpos,SEEK_SET);
if (offset < 0)
return(-1);
savedolen = 0L;
}
credit:www.vackbot.com(墨云科技)