Fix memory leaks when we have a path option in a config file.

Sadly this requires some nasty looking if checks all over main, but it's
the only way to do it.

stat has memory issues if you don't give it a struct stat, ugh.