]> granicus.if.org Git - postgresql/commitdiff
Fix crash caused by NULL lookup when reporting IP address of failed
authorBruce Momjian <bruce@momjian.us>
Thu, 16 Dec 2010 15:13:43 +0000 (10:13 -0500)
committerBruce Momjian <bruce@momjian.us>
Thu, 16 Dec 2010 15:13:43 +0000 (10:13 -0500)
libpq connection, per report from Magnus.  This happens only on GIT
master and only on Win32 because that is the platform where "" maps to
an IP address (localhost).

src/interfaces/libpq/fe-connect.c

index b1523a6a893422af5df9bd25abbe6da9d554aa42..8d9400be0fc7c30f27a7ac949912d79ef7da4be3 100644 (file)
@@ -1031,7 +1031,8 @@ connectFailureMessage(PGconn *conn, int errorno)
                        strcpy(host_addr, "???");
 
                display_host_addr = (conn->pghostaddr == NULL) &&
-                       (strcmp(conn->pghost, host_addr) != 0);
+                                                       (conn->pghost != NULL) &&
+                                                       (strcmp(conn->pghost, host_addr) != 0);
 
                appendPQExpBuffer(&conn->errorMessage,
                                                  libpq_gettext("could not connect to server: %s\n"