MagickGetImageFormat() returns a const char*, and since there is only a relatively small set of supported image formats, I expected it to return a pointer to a string literal.
However, it does not. Bizarrely, it allocates heap memory. Failure to return this memory results in a memory leak (typically only 4-5 bytes, but this locks up a 4K memory page, causing a >2Gb memory leak/week on my servers!)
Other functions, such as MagickGetImageChannelStatistics(), document that the returned pointer must be passed to MagickRelinquishMemory().
MagickGetImageFormat() should include the same documentation, or else it should stop allocating on the heap.
Unexpected memory usage in MagickGetImageFormat()
Re: Unexpected memory usage in MagickGetImageFormat()
MagickGetImageFormat() is incorrectly documented. We'll fix that by sometime tomorrow. It returns a char * which should be freed with free() when it is no longer needed.