Don't write past end of memory when loading contents.