]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't pass NULL to fprintf, if not currently connected to a database.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 15 Jan 2013 16:54:03 +0000 (18:54 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 15 Jan 2013 17:20:42 +0000 (19:20 +0200)
Backpatch all the way to 8.3. Fixes bug #7811, per report and diagnosis by
Meng Qingzhong.

src/bin/psql/help.c

index 5e52259df8a64e71bdb230b831485d2a6eae1272..cfe597213768313b6c77030d0e99b619141fd429 100644 (file)
@@ -159,6 +159,11 @@ void
 slashUsage(unsigned short int pager)
 {
        FILE       *output;
+       char       *currdb;
+
+       currdb = PQdb(pset.db);
+       if (currdb == NULL)
+               currdb = _("none");
 
        output = PageOutput(69, pager);
 
@@ -171,7 +176,7 @@ slashUsage(unsigned short int pager)
        fprintf(output, _("General\n"));
        fprintf(output, _("  \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
                        "                 connect to new database (currently \"%s\")\n"),
-                       PQdb(pset.db));
+                       currdb);
        fprintf(output, _("  \\cd [DIR]      change the current working directory\n"));
        fprintf(output, _("  \\copyright     show PostgreSQL usage and distribution terms\n"));
        fprintf(output, _("  \\encoding [ENCODING]\n"