Skip to content

Commit 14fa980

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 d4c78c1 commit 14fa980

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
@@ -157,6 +157,11 @@ void
157157
slashUsage(unsigned short int pager)
158158
{
159159
FILE *output;
160+
char *currdb;
161+
162+
currdb = PQdb(pset.db);
163+
if (currdb == NULL)
164+
currdb = _("none");
160165

161166
output = PageOutput(92, pager);
162167

@@ -248,7 +253,7 @@ slashUsage(unsigned short int pager)
248253
fprintf(output, _("Connection\n"));
249254
fprintf(output, _(" \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
250255
" connect to new database (currently \"%s\")\n"),
251-
PQdb(pset.db));
256+
currdb);
252257
fprintf(output, _(" \\encoding [ENCODING] show or set client encoding\n"));
253258
fprintf(output, _(" \\password [USERNAME] securely change the password for a user\n"));
254259
fprintf(output, _(" \\conninfo display information about current connection\n"));

0 commit comments

Comments
 (0)