emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pq 83157bd41e 32/63: Cleanup session initialization.


From: ELPA Syncer
Subject: [elpa] externals/pq 83157bd41e 32/63: Cleanup session initialization.
Date: Mon, 14 Feb 2022 23:24:24 -0500 (EST)

branch: externals/pq
commit 83157bd41ea3403efc624888bb96e85521860ee9
Author: Andreas Seltenreich <seltenreich@gmx.de>
Commit: Andreas Seltenreich <seltenreich@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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]