Fix error when filename is null

Seen occasionally on Windows when running test/file.jl

This has been reported before [here](https://github.com/JuliaLang/julia/issues/5305#issuecomment-33313637), and in older versions of this function anything involving the filename had been commented out for this same reason of it occasionally being null. I don't fully understand where this is coming from, so apologies if this change is detrimental in any way.