Fixed crash when handed corrupt or incomplete file.