res_config_pgsql: Fix a memory leak and use RAII_VAR for cleanup when practical