Patch a logic error in access_memory()