Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/bin/initdb/initdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ setup_cdb_schema(FILE *cmdfd)

/* Collect all files with .sql suffix in array. */
nscripts = 0;
while ((file = readdir(dir)) != NULL)
while (errno = 0, (file = readdir(dir)) != NULL)
{
int namelen = strlen(file->d_name);

Expand Down Expand Up @@ -2054,12 +2054,16 @@ setup_cdb_schema(FILE *cmdfd)
errno = 0;
#endif

closedir(dir);

if (errno != 0)
{
/* some kind of I/O error? */
pg_log_error("error while reading cdb_init.d directory: %m");
closedir(dir);
exit(1);
}

if (closedir(dir))
{
pg_log_error("error while closing cdb_init.d directory: %m");
exit(1);
}

Expand Down
Loading