Here is the critical code : (in WritePNMImage)
for (j=0; j < 16; j++) //1982
{
red_map[i][j]=MagickAllocateMemory(unsigned short *, //1984
256*sizeof(unsigned short));
green_map[i][j]=MagickAllocateMemory(unsigned short *,
256*sizeof(unsigned short));
blue_map[i][j]=MagickAllocateMemory(unsigned short *,
256*sizeof(unsigned short));
if ((red_map[i][j] == (unsigned short *) NULL) ||
(green_map[i][j] == (unsigned short *) NULL) ||
(blue_map[i][j] == (unsigned short *) NULL))
ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
image);
}
If one of the “red_map[i][j]”、“green_map[i][j]” and “blue_map[i][j]" is not null in “if statement”,it may cause memory leak error.
Credit : ADLab of Venustech
This problem is fixed by Mercurial changeset 15213:011296e737a1. Thanks for the report!