mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -157,6 +157,11 @@ void
 | 
				
			|||||||
slashUsage(unsigned short int pager)
 | 
					slashUsage(unsigned short int pager)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	FILE	   *output;
 | 
						FILE	   *output;
 | 
				
			||||||
 | 
						char	   *currdb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						currdb = PQdb(pset.db);
 | 
				
			||||||
 | 
						if (currdb == NULL)
 | 
				
			||||||
 | 
							currdb = _("none");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	output = PageOutput(92, pager);
 | 
						output = PageOutput(92, pager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -248,7 +253,7 @@ slashUsage(unsigned short int pager)
 | 
				
			|||||||
	fprintf(output, _("Connection\n"));
 | 
						fprintf(output, _("Connection\n"));
 | 
				
			||||||
	fprintf(output, _("  \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
 | 
						fprintf(output, _("  \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
 | 
				
			||||||
	"                         connect to new database (currently \"%s\")\n"),
 | 
						"                         connect to new database (currently \"%s\")\n"),
 | 
				
			||||||
			PQdb(pset.db));
 | 
								currdb);
 | 
				
			||||||
	fprintf(output, _("  \\encoding [ENCODING]   show or set client encoding\n"));
 | 
						fprintf(output, _("  \\encoding [ENCODING]   show or set client encoding\n"));
 | 
				
			||||||
	fprintf(output, _("  \\password [USERNAME]   securely change the password for a user\n"));
 | 
						fprintf(output, _("  \\password [USERNAME]   securely change the password for a user\n"));
 | 
				
			||||||
	fprintf(output, _("  \\conninfo              display information about current connection\n"));
 | 
						fprintf(output, _("  \\conninfo              display information about current connection\n"));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user