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

Commitf175884

Browse files
committed
Properly close files after read file failure to prevent potential
resource leak. Of course, any such failure aborts pg_upgrade, but mightas well be clean about it.Per patch from Grzegorz Ja?kiewicz.
1 parent112c3fc commitf175884

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

‎contrib/pg_upgrade/file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ copyAndUpdateFile(migratorContext *ctx, pageCnvCtx *pageConverter,
7474
return"can't open source file";
7575

7676
if ((dstfd=open(dst,O_RDWR |O_CREAT |O_EXCL,S_IRUSR |S_IWUSR))<0)
77+
{
78+
fclose(src_fd);
7779
return"can't create destination file";
80+
}
7881

7982
while ((bytesRead=read(src_fd,buf,BLCKSZ))==BLCKSZ)
8083
{

‎contrib/pg_upgrade/page.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ getPageVersion(migratorContext *ctx, uint16 *version, const char *pathName)
103103
return"can't open relation";
104104

105105
if ((bytesRead=read(relfd,&page,sizeof(page)))!=sizeof(page))
106+
{
107+
close(relfd);
106108
return"can't read page header";
109+
}
107110

108111
*version=PageGetPageLayoutVersion(&page);
109112

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp