Fix problem detecting corrupt memory