branch: externals/pq commit 83157bd41ea3403efc624888bb96e85521860ee9 Author: Andreas Seltenreich <seltenre...@gmx.de> Commit: Andreas Seltenreich <seltenre...@gmx.de>
Cleanup session initialization. We still would have leaked some memory if an error occured during session initialization. --- pq.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pq.c b/pq.c index 8fb7726377..9694ec1994 100644 --- a/pq.c +++ b/pq.c @@ -100,13 +100,17 @@ Fpq_connectdb (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data) } /* The emacs-module interface always expects utf8 strings */ - PGresult *res = PQexec(conn, "set client_encoding to utf8"); - if (!result_ok(env, res)) - return Qnil; - PQclear(res); - res = PQexec(conn, "set application_name to emacs"); - if (!result_ok(env, res)) + PGresult *res = + PQexec(conn, + "set client_encoding to utf8;" + "set application_name to emacs;"); + + if (!result_ok(env, res)) { + if (nargs) + free(conninfo); + PQfinish(conn); return Qnil; + } PQclear(res); if (nargs)