Skip to content
This repository was archived by the owner on Jan 11, 2026. It is now read-only.

Commit 09d306a

Browse files
Check if fread returned 0
1 parent 420383e commit 09d306a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/parsers/text_plain.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ void parse_file(const char *pathname, String *str) {
1313
fprintf(stderr, "Could not open file: %s : %s\n", pathname, strerror(errno));
1414
exit(1);
1515
}
16-
fread(str->str, str->size, 1, fp);
16+
size_t read_bytes = fread(str->str, str->size, 1, fp);
17+
if (read_bytes == 0) {
18+
fprintf(stderr, "Error, reading contents of: %s", pathname);
19+
}
1720
fclose(fp);
1821
}
1922
#pragma GCC diagnostic pop

0 commit comments

Comments
 (0)