The security advisory pointed to a memory leak in the VIFF encoder of ImageMagick. By analyzing the commits between the last vulnerable version and the first patched version, I identified the exact commit that fixes the issue. The commit fdbf39ba9a681e53e6025d40501ae5a2bfec3000 modifies the WriteVIFFImage function in coders/viff.c. The patch explicitly shows that a memory release was missing in an error handling path. Specifically, if the allocation for viff_colormap failed, the memory for pixel_info was not being released. The fix was to add pixel_info=RelinquishVirtualMemory(pixel_info); before the exception is thrown. Therefore, the WriteVIFFImage function is the vulnerable function.