mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Fix yesno_prompt() memory leak in /script tools, reported by Converity.
This commit is contained in:
parent
0a42adcc32
commit
fb541a1b59
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.22 2006/09/22 19:51:14 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.23 2006/10/03 21:45:20 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -208,20 +208,28 @@ yesno_prompt(const char *question)
|
|||||||
{
|
{
|
||||||
char prompt[256];
|
char prompt[256];
|
||||||
|
|
||||||
|
/* translator: This is a question followed by the translated options for "yes" and "no". */
|
||||||
|
snprintf(prompt, sizeof(prompt), _("%s (%s/%s) "),
|
||||||
|
_(question), _(PG_YESLETTER), _(PG_NOLETTER));
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char *resp;
|
char *resp;
|
||||||
|
|
||||||
/* translator: This is a question followed by the translated options for "yes" and "no". */
|
|
||||||
snprintf(prompt, sizeof(prompt), _("%s (%s/%s) "),
|
|
||||||
_(question), _(PG_YESLETTER), _(PG_NOLETTER));
|
|
||||||
resp = simple_prompt(prompt, 1, true);
|
resp = simple_prompt(prompt, 1, true);
|
||||||
|
|
||||||
if (strcmp(resp, _(PG_YESLETTER)) == 0)
|
if (strcmp(resp, _(PG_YESLETTER)) == 0)
|
||||||
|
{
|
||||||
|
free(resp);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else if (strcmp(resp, _(PG_NOLETTER)) == 0)
|
else if (strcmp(resp, _(PG_NOLETTER)) == 0)
|
||||||
|
{
|
||||||
|
free(resp);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(resp);
|
||||||
printf(_("Please answer \"%s\" or \"%s\".\n"),
|
printf(_("Please answer \"%s\" or \"%s\".\n"),
|
||||||
_(PG_YESLETTER), _(PG_NOLETTER));
|
_(PG_YESLETTER), _(PG_NOLETTER));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user