8000 Don't pass NULL to fprintf, if not currently connected to a database. · home201448/postgres@63b0b39 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63b0b39

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 0af83bd commit 63b0b39

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
@@ -159,6 +159,11 @@ void
159159
slashUsage(unsigned short int pager)
160160
{
161161
FILE *output;
162+
char *currdb;
163+
164+
currdb = PQdb(pset.db);
165+
if (currdb == NULL)
166+
currdb = _("none");
162167

163168
output = PageOutput(69, pager);
164169

@@ -171,7 +176,7 @@ slashUsage(unsigned short int pager)
171176
fprintf(output, _("General\n"));
172177
fprintf(output, _(" \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
173178
" connect to new database (currently \"%s\")\n"),
174-
PQdb(pset.db));
179+
currdb);
175180
fprintf(output, _(" \\cd [DIR] change the current working directory\n"));
176181
fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n"));
177182
fprintf(output, _(" \\encoding [ENCODING]\n"

0 commit comments

Comments
 (0)
0