Exit the ./gen program on failed readdir() call

(cherry picked from commit 05b7c08a16)
This commit is contained in:
Ondřej Surý 2019-05-21 17:56:58 +00:00
parent 477515fb09
commit a17eb8dec4

View file

@ -28,8 +28,10 @@
#include <sys/types.h> /* Required on some systems for dirent.h. */
#include <errno.h>
#include <dirent.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h> /* XXXDCL Required for ?. */
#include <isc/lang.h>
@ -66,9 +68,15 @@ next_file(isc_dir_t *dir) {
dir->filename = NULL;
if (dir->handle != NULL) {
errno = 0;
dirent = readdir(dir->handle);
if (dirent != NULL)
if (dirent != NULL) {
dir->filename = dirent->d_name;
} else {
if (errno != 0) {
exit(1);
}
}
}
if (dir->filename != NULL)