Here is the critical code : (in WriteGIFImage)
global_colormap=MagickAllocateMemory(unsigned char *,768); //1295
colormap=MagickAllocateMemory(unsigned char *,768);
if ((global_colormap == (unsigned char *) NULL) ||
(colormap == (unsigned char *) NULL))
ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
The global_colormap and colormap are not freed before Exception, so it will cause memory leak.
Credit : ADLab of Venustech
This problem is fixed by Mercurial changeset 15197:57ea336cefaa. Thanks for the report!