The PNG chunk reader fails to enforce proper chunk ordering, allowing an IHDR chunk to be processed multiple times. If a second IHDR chunk appears after an IDAT chunk, it can overwrite image dimensions, bit depth, and pixel depth after the decoded-data buffer has been allocated and filled. This causes the process that reverses PNG row filters to use the new dimensions while operating on the original buffer, leading to memory corruption as image bytes are written beyond the buffer boundaries.