aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2006-06-19 09:20:22 +0000
committerMichael Meskes <meskes@postgresql.org>2006-06-19 09:20:22 +0000
commit14f52896b8ac944b6a487275a90bce9f3d8f7796 (patch)
tree38a07ed4fe942d88ed0caa7b6ffd75d1fa7b1869
parent605cb39576cb1b15fc4b44a22543393317392603 (diff)
downloadpostgresql-14f52896b8ac944b6a487275a90bce9f3d8f7796.tar.gz
postgresql-14f52896b8ac944b6a487275a90bce9f3d8f7796.zip
Do not use already free'ed errmsg, bug found by Joachim Wieland
<joachim.wieland@credativ.de>
-rw-r--r--src/interfaces/ecpg/ecpglib/connect.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 3f0bc62fa5d..94acd32656d 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.24.4.2 2005/11/30 12:51:06 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.24.4.3 2006/06/19 09:20:22 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -451,10 +451,6 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
const char *errmsg = PQerrorMessage(this->connection);
char *db = realname ? realname : "<DEFAULT>";
- ecpg_finish(this);
-#ifdef ENABLE_THREAD_SAFETY
- pthread_mutex_unlock(&connections_mutex);
-#endif
ECPGlog("connect: could not open database %s on %s port %s %s%s%s%s in line %d\n\t%s\n",
db,
host ? host : "<DEFAULT>",
@@ -463,6 +459,11 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
user ? "for user " : "", user ? user : "",
lineno, errmsg);
+ ecpg_finish(this);
+#ifdef ENABLE_THREAD_SAFETY
+ pthread_mutex_unlock(&connections_mutex);
+#endif
+
ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, db);
if (host)
ECPGfree(host);