diff --git a/file_ops.c b/file_ops.c index 55d2a18cdc..fb874e748c 100644 --- a/file_ops.c +++ b/file_ops.c @@ -107,13 +107,15 @@ static bool read_generic_file(const char *path, void **buf, ssize_t *len) if (!file) goto error; - fseek(file, 0, SEEK_END); + if (fseek(file, 0, SEEK_END) != 0) + goto error; _len = ftell(file); if (_len < 0) goto error; - rewind(file); + if (fseek(file, 0, SEEK_SET) != 0) + goto error; rom_buf = malloc(_len + 1);