From: Michael Meskes Date: Mon, 19 Jun 2006 09:20:22 +0000 (+0000) Subject: Do not use already free'ed errmsg, bug found by Joachim Wieland X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3d13267d67c87ee911d482f008475193c08dce31;p=users%2Fbernd%2Fpostgres.git Do not use already free'ed errmsg, bug found by Joachim Wieland --- diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index d8d32dbd76..6269abb998 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -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 : ""; - 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 : "", @@ -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);