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

Commiteb93316

Browse files
committed
Fix issues with pg_ctl
The new, small, free_readfile managed to have bug in it which couldcause it to try and free something it shouldn't, and fix the casewhere it was being called with an invalid pointer leading to asegfault.Noted by Bruce, issues introduced and fixed by me.
1 parent6f37c08 commiteb93316

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,14 @@ readfile(const char *path)
376376
void
377377
free_readfile(char**optlines)
378378
{
379-
inti=0;
379+
char*curr_line=NULL;
380+
inti=0;
380381

381382
if (!optlines)
382383
return;
383384

384-
while (optlines[i++])
385-
free(optlines[i]);
385+
while ((curr_line=optlines[i++]))
386+
free(curr_line);
386387

387388
free(optlines);
388389

@@ -1224,15 +1225,16 @@ do_status(void)
12241225
if (postmaster_is_alive((pid_t)pid))
12251226
{
12261227
char**optlines;
1228+
char**curr_line;
12271229

12281230
printf(_("%s: server is running (PID: %ld)\n"),
12291231
progname,pid);
12301232

12311233
optlines=readfile(postopts_file);
12321234
if (optlines!=NULL)
12331235
{
1234-
for (;*optlines!=NULL;optlines++)
1235-
fputs(*optlines,stdout);
1236+
for (curr_line=optlines;*curr_line!=NULL;curr_line++)
1237+
fputs(*curr_line,stdout);
12361238

12371239
/* Free the results of readfile */
12381240
free_readfile(optlines);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp