Check for nil resource files

This is enough to fix the crash in #3719. 

See also #3720 for other fixes in this neighborhood.