Here is the critical code:
…
formats=MagickAllocateMemory(char **,(i+1)*sizeof(char *)); //4835
i=0;
for (p=magick_info; p != (MagickInfo *) NULL; p=p->next)
{
if (p->stealth)
continue;
if (!p->encoder)
continue;
formats[i]=AllocateString(p->name);
LocaleLower((char *) formats[i]);
i++;
}
…
MagickAllocateMemory(...) may return NULL, so the following operations on the “formats" will dereference null pointer to cause memory error.
Credit: ADLab of Venustech
This problem is fixed by Mercurial changeset 15209:0f827e035339. Thanks for the report!