diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-06-19 09:20:07 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-06-19 09:20:07 +0000 |
commit | 23623f05f05fcdc3142e83bf21cf4dc10e16aafd (patch) | |
tree | 2752c7208f9e6c8cb6915aeb4f40337d83196287 | |
parent | 63b103aac83e41dd418113d0e252bacfd5cb98d6 (diff) | |
download | postgresql-23623f05f05fcdc3142e83bf21cf4dc10e16aafd.tar.gz postgresql-23623f05f05fcdc3142e83bf21cf4dc10e16aafd.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.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 69f81f2151c..0964fa8a8f9 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.26.2.1 2005/11/30 12:50:37 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.2 2006/06/19 09:20:07 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -456,10 +456,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>", @@ -468,6 +464,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); |