diff --git a/include/flatcc/support/readfile.h b/include/flatcc/support/readfile.h index 209875fb..a262b215 100644 --- a/include/flatcc/support/readfile.h +++ b/include/flatcc/support/readfile.h @@ -32,7 +32,7 @@ static char *readfile(const char *filename, size_t max_size, size_t *size_out) if (max_size > 0 && size > max_size) { goto fail; } - rewind(fp); + if (fseek(fp, 0L, SEEK_SET)) goto fail; buf = (char *)malloc(size ? size : 1); if (!buf) { goto fail; diff --git a/src/compiler/fileio.c b/src/compiler/fileio.c index 56d88c11..c9edaf1b 100644 --- a/src/compiler/fileio.c +++ b/src/compiler/fileio.c @@ -197,7 +197,7 @@ char *fb_read_file(const char *filename, size_t max_size, size_t *size_out) if (max_size > 0 && size > max_size) { goto fail; } - rewind(fp); + if (fseek(fp, 0L, SEEK_SET)) goto fail; buf = malloc(size ? size : 1); if (!buf) { goto fail;