File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.61 1997/05/22 18:55:35 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.62 1997/05/22 23:57:27 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -836,18 +836,19 @@ do_connect(const char *new_dbname,
836
836
fprintf (stderr , "\\connect must be followed by a database name\n" );
837
837
else {
838
838
PGconn * olddb = settings -> db ;
839
- char * userenv ;
839
+ static char * userenv = NULL ;
840
840
841
841
printf ("closing connection to database: %s\n" , dbname );
842
842
if (new_user != NULL ) {
843
843
/*
844
844
PQsetdb() does not allow us to specify the user,
845
845
so we have to do it via PGUSER
846
846
*/
847
+ if (userenv != NULL )
848
+ free (userenv );
847
849
userenv = malloc (strlen ("PGUSER=" ) + strlen (new_user ) + 1 );
848
850
sprintf (userenv ,"PGUSER=%s" ,new_user );
849
- putenv (userenv );
850
- free (userenv );
851
+ putenv (userenv ); /* putenv() continues to use memory in env. */
851
852
}
852
853
settings -> db = PQsetdb (PQhost (olddb ), PQport (olddb ),
853
854
NULL , NULL , new_dbname );
You can’t perform that action at this time.
0 commit comments