Skip to content

Commit fb541a1

Browse files
committed
Fix yesno_prompt() memory leak in /script tools, reported by Converity.
1 parent 0a42adc commit fb541a1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/bin/scripts/common.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.22 2006/09/22 19:51:14 tgl Exp $
10+
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.23 2006/10/03 21:45:20 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -208,20 +208,28 @@ yesno_prompt(const char *question)
208208
{
209209
char prompt[256];
210210

211+
/* translator: This is a question followed by the translated options for "yes" and "no". */
212+
snprintf(prompt, sizeof(prompt), _("%s (%s/%s) "),
213+
_(question), _(PG_YESLETTER), _(PG_NOLETTER));
214+
211215
for (;;)
212216
{
213217
char *resp;
214218

215-
/* translator: This is a question followed by the translated options for "yes" and "no". */
216-
snprintf(prompt, sizeof(prompt), _("%s (%s/%s) "),
217-
_(question), _(PG_YESLETTER), _(PG_NOLETTER));
218219
resp = simple_prompt(prompt, 1, true);
219220

220221
if (strcmp(resp, _(PG_YESLETTER)) == 0)
222+
{
223+
free(resp);
221224
return true;
225+
}
222226
else if (strcmp(resp, _(PG_NOLETTER)) == 0)
227+
{
228+
free(resp);
223229
return false;
230+
}
224231

232+
free(resp);
225233
printf(_("Please answer \"%s\" or \"%s\".\n"),
226234
_(PG_YESLETTER), _(PG_NOLETTER));
227235
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy