Bug 634964: Crash in pgsql_error_fn. The dbi_conn isn't set if the server refuses the connection, so protect dereferences from null pointers.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19820 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2010-11-17 00:10:16 +00:00
parent 1b26fa2bcb
commit 24b4493e2b

View File

@ -847,13 +847,19 @@ pgsql_error_fn( dbi_conn conn, void* user_data )
}
else if ( g_strrstr( msg, "server closed the connection unexpectedly" ) ) // Connection lost
{
if ( dbi_conn == NULL )
{
PWARN( "DBI Error: Connection lost, connection pointer invalid");
return;
}
PINFO( "DBI error: %s - Reconnecting...\n", msg );
gnc_dbi_set_error( dbi_conn, ERR_BACKEND_CONN_LOST, 1, TRUE );
dbi_conn->conn_ok = TRUE;
(void)dbi_conn_connect( conn );
}
else if ( g_str_has_prefix( msg, "connection pointer is NULL" ) ||
g_str_has_prefix(msg, "could not connect to server" ) ) // No connection
else if ( dbi_conn &&
( g_str_has_prefix( msg, "connection pointer is NULL" ) ||
g_str_has_prefix(msg, "could not connect to server" ) ) ) // No connection
{
if (dbi_conn->error_repeat >= DBI_MAX_CONN_ATTEMPTS )
{