Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ext/pg_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,16 @@ static VALUE
pgconn_reset_start2( VALUE self, VALUE conninfo )
{
t_pg_connection *this = pg_get_connection( self );
/* Ensure conninfo is a valid C string before closing the connection. */
char *p_conninfo = StringValueCStr(conninfo);

/* Close old connection */
pgconn_close_socket_io( self );
PQfinish( this->pgconn );
this->pgconn = NULL; /* Ensure no double free can happen. */

/* Start new connection */
this->pgconn = gvl_PQconnectStart( StringValueCStr(conninfo) );
this->pgconn = gvl_PQconnectStart( p_conninfo );

if( this->pgconn == NULL )
rb_raise(rb_ePGerror, "PQconnectStart() unable to allocate PGconn structure");
Expand Down
Loading