===================================================================
@@ -2200,6 +2200,8 @@ load_file (const char *realfilename, const char *d
FILE *input;
int len, line_len;
bool first_line;
+ struct stat st;
+ int stat_result;
const char *filename;
/* If realfilename and displayedname are different and non-null then
surely realfilename is the preprocessed form of
@@ -2242,6 +2244,16 @@ load_file (const char *realfilename, const char *d
current_file->filename, current_file->line, filename);
return false;
}
+
+ stat_result = stat (realfilename, &st);
+ if (stat_result == 0 && st.st_mode & S_IFDIR)
+ {
+ fprintf (stderr, "%s:%d: Error: Included path '%s'"
+ " is a directory.\n",
+ current_file->filename, current_file->line, filename);
+ fclose (input);
+ return false;
+ }
}
/* Load the file.