Don't pass NULL to fprintf, if a bogus connection string is given to pg_dump.
authorHeikki Linnakangas
Wed, 20 Feb 2013 14:22:47 +0000 (16:22 +0200)
committerHeikki Linnakangas
Wed, 20 Feb 2013 14:34:16 +0000 (16:34 +0200)
Back-patch to all supported branches.

src/bin/pg_dump/pg_backup_db.c

index c295fc5ddd2078978f9851ff554fadc7aaad456d..21d050ffa01e271c39da94c7ab8c540b1a4ed90a 100644 (file)
@@ -301,7 +301,8 @@ ConnectDatabase(Archive *AHX,
    /* check to see that the backend connection was successfully made */
    if (PQstatus(AH->connection) == CONNECTION_BAD)
        exit_horribly(modulename, "connection to database \"%s\" failed: %s",
-                     PQdb(AH->connection), PQerrorMessage(AH->connection));
+                     PQdb(AH->connection) ? PQdb(AH->connection) : "",
+                     PQerrorMessage(AH->connection));
 
    /* check for version mismatch */
    _check_database_version(AH);