r19820 - gnucash/trunk/src/backend/dbi - 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.
John Ralls
jralls at code.gnucash.org
Tue Nov 16 19:10:16 EST 2010
Author: jralls
Date: 2010-11-16 19:10:16 -0500 (Tue, 16 Nov 2010)
New Revision: 19820
Trac: http://svn.gnucash.org/trac/changeset/19820
Modified:
gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
Log:
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.
Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2010-11-16 22:07:58 UTC (rev 19819)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2010-11-17 00:10:16 UTC (rev 19820)
@@ -847,13 +847,19 @@
}
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 )
{
More information about the gnucash-changes
mailing list