From a8fea21f119b4b466fe3471ad60d7df6510fd145 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Feb 2015 17:57:49 -0500 Subject: [PATCH] additional error tracking on reading file streams if `fseek` fails --- file_ops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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);