Same issue also affects memory.c, so attached the diff with changes to memory.c ...
Fix broken checks