Avoid duplicate frees when scanning.