Skip to content

Commit bb9a9a9

Browse files
committed
Don't pass NULL to fprintf, if not currently connected to a database.
Backpatch all the way to 8.3. Fixes bug #7811, per report and diagnosis by Meng Qingzhong.
1 parent 78298da commit bb9a9a9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/bin/psql/help.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ void
161161
slashUsage(unsigned short int pager)
162162
{
163163
FILE *output;
164+
char *currdb;
165+
166+
currdb = PQdb(pset.db);
167+
if (currdb == NULL)
168+
currdb = _("none");
164169

165170
output = PageOutput(86, pager);
166171

@@ -246,7 +251,7 @@ slashUsage(unsigned short int pager)
246251
fprintf(output, _("Connection\n"));
247252
fprintf(output, _(" \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
248253
" connect to new database (currently \"%s\")\n"),
249-
PQdb(pset.db));
254+
currdb);
250255
fprintf(output, _(" \\encoding [ENCODING] show or set client encoding\n"));
251256
fprintf(output, _(" \\password [USERNAME] securely change the password for a user\n"));
252257
fprintf(output, "\n");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy