fixed bug in connect.c
authorMichael Meskes
Fri, 15 Jun 2001 09:55:51 +0000 (09:55 +0000)
committerMichael Meskes
Fri, 15 Jun 2001 09:55:51 +0000 (09:55 +0000)
src/interfaces/ecpg/lib/connect.c

index 5dc05ea7402b84ddd5cf8e2a9028936787287a34..2618cc37ed8f865190af0c8f4838be9d0ab1d5b3 100644 (file)
@@ -411,17 +411,6 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
 
    this->connection = PQsetdbLogin(host, port, options, NULL, realname, user, passwd);
 
-   if (host)
-       free(host);
-   if (port)
-       free(port);
-   if (options)
-       free(options);
-   if (realname)
-       free(realname);
-   if (dbname)
-       free(dbname);
-
    if (PQstatus(this->connection) == CONNECTION_BAD)
    {
        ecpg_finish(this);
@@ -433,9 +422,30 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
                user ? "for user " : "", user ? user : "",
                lineno);
        ECPGraise(lineno, ECPG_CONNECT, realname ? realname : "");
+       if (host)
+           free(host);
+       if (port)
+           free(port);
+       if (options)
+           free(options);
+       if (realname)
+           free(realname);
+       if (dbname)
+           free(dbname);
        return false;
    }
 
+   if (host)
+       free(host);
+   if (port)
+       free(port);
+   if (options)
+       free(options);
+   if (realname)
+       free(realname);
+   if (dbname)
+       free(dbname);
+
    this->committed = true;
    this->autocommit = autocommit;