Handle NULs in link targets in Pathname#resolved_path_exists?

Fixes #19475.
Fixes #21184.