diff --git a/tests/json_test.c b/tests/json_test.c index 7fcd6f8..12da188 100644 --- a/tests/json_test.c +++ b/tests/json_test.c @@ -87,17 +87,20 @@ void parse_single_file(const char *path) struct stat sb = { 0 }; WantError = 0; /* open our file */ - if (stat(path, &sb) == -1) { + + fh = fopen(path, "r"); + if (fh == NULL) { perror(path); return; } - if (S_ISDIR(sb.st_mode)) { - fprintf(stderr, "Skipping directory '%s'\n", path); + + if (fstat(fileno(fh), &sb) != 0) { + fclose(fh); return; } - fh = fopen(path, "r"); - if (fh == NULL) { - perror(path); + + if (S_ISDIR(sb.st_mode)) { + fprintf(stderr, "Skipping directory '%s'\n", path); return; }