Check for NULL when looking up getenv("HOME").
Merge pull request #3980 from quickfur/issue12130

Check for NULL when looking up getenv("HOME").