In some cases when an error occurs reading those parts of a JPEG file after the image the scan-line buffer could be freed a second time. In cases where the the error occured while reading the image data it's possible that the buffer could have leaked. Thanks to Gabriel Vasseur for reporting this and help in tracking it down.