diff options
author | Bruce Momjian <bruce@momjian.us> | 2014-03-21 13:45:11 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2014-03-21 13:45:11 -0400 |
commit | 6f03927fce038096f53ca67eeab9adb24938f8a6 (patch) | |
tree | e6ebc4031e1ec37c0766e1ae6baa83f39b0da227 /src/port/dirent.c | |
parent | 68a2e52bbaf98f136a96b3a0d734ca52ca440a95 (diff) | |
download | postgresql-6f03927fce038096f53ca67eeab9adb24938f8a6.tar.gz postgresql-6f03927fce038096f53ca67eeab9adb24938f8a6.zip |
Properly check for readdir/closedir() failures
Clear errno before calling readdir() and handle old MinGW errno bug
while adding full test coverage for readdir/closedir failures.
Backpatch through 8.4.
Diffstat (limited to 'src/port/dirent.c')
-rw-r--r-- | src/port/dirent.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/port/dirent.c b/src/port/dirent.c index f9d93ea7d86..3bdc03e9b44 100644 --- a/src/port/dirent.c +++ b/src/port/dirent.c @@ -105,15 +105,19 @@ readdir(DIR *d) strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH * long */ d->ret.d_namlen = strlen(d->ret.d_name); + return &d->ret; } int closedir(DIR *d) { + int ret = 0; + if (d->handle != INVALID_HANDLE_VALUE) - FindClose(d->handle); + ret = !FindClose(d->handle); free(d->dirname); free(d); - return 0; + + return ret; } |