Fix use after free
Close fp after reading configuration
Don't leak version on error