1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Fix file descriptor leaks in pg_upgrade in failure code paths.

This commit is contained in:
Bruce Momjian
2011-03-08 21:35:42 -05:00
parent 51c0124481
commit d367d41d66
5 changed files with 34 additions and 17 deletions

View File

@ -302,7 +302,10 @@ pg_scandir_internal(const char *dirname,
(size_t) ((name_num + 1) * sizeof(struct dirent *)));
if (*namelist == NULL)
{
closedir(dirdesc);
return -1;
}
entrysize = sizeof(struct dirent) - sizeof(direntry->d_name) +
strlen(direntry->d_name) + 1;
@ -310,7 +313,10 @@ pg_scandir_internal(const char *dirname,
(*namelist)[name_num] = (struct dirent *) malloc(entrysize);
if ((*namelist)[name_num] == NULL)
{
closedir(dirdesc);
return -1;
}
memcpy((*namelist)[name_num], direntry, entrysize);