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

Commitcec62ef

Browse files
committed
Be sure to close() file descriptor on error case
In receivelog.c:writeTimeLineHistoryFile(), we were not properlyclosing the open'd file descriptor in error cases. While thiswouldn't matter much if we were about to exit due to such anerror, that's not the case with pg_receivexlog as it can be along-running process and these errors are non-fatal.This resource leak was found by the Coverity scanner.Back-patch to 9.3 where this issue first appeared.
1 parent273dcd1 commitcec62ef

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ writeTimeLineHistoryFile(char *basedir, TimeLineID tli, char *filename, char *co
329329
/*
330330
* If we fail to make the file, delete it to release disk space
331331
*/
332+
close(fd);
332333
unlink(tmppath);
333334
errno=save_errno;
334335

@@ -339,6 +340,7 @@ writeTimeLineHistoryFile(char *basedir, TimeLineID tli, char *filename, char *co
339340

340341
if (fsync(fd)!=0)
341342
{
343+
close(fd);
342344
fprintf(stderr,_("%s: could not fsync file \"%s\": %s\n"),
343345
progname,tmppath,strerror(errno));
344346
return false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp