ImageMagick before 6.9.13-61 and 7.x before 7.1.2-36 contains a heap buffer overflow in encoders that export pixels for 12-bit images before encoding the image data. Attackers can supply a crafted image that, when processed and encoded, triggers an out-of-bounds heap write, causing crashes or memory corruption.