Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb541a1

Browse files
committed
Fix yesno_prompt() memory leak in /script tools, reported by Converity.
1 parent0a42adc commitfb541a1

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
charprompt[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
elseif (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)

[8]ページ先頭

©2009-2025 Movatter.jp