summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2020-11-13 14:12:18 +0000
committerPhilip Withnall <pwithnall@endlessos.org>2020-11-13 14:12:18 +0000
commit895da996948d41d98acf40378b3f6c40efc0aace (patch)
treeb1eae28741a903edc4e172a47a2c15bf11b97305
parenta8bc60498867226c377cc1fb5d8ee60c6b4625cb (diff)
downloadglib-895da996948d41d98acf40378b3f6c40efc0aace.tar.gz
fuzzing: Fix minor Coverity warning about return values
ftell() could theoretically fail; handle that. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Coverity CID: #1430667
-rw-r--r--fuzzing/driver.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fuzzing/driver.c b/fuzzing/driver.c
index 99e965ba6..f6d2396db 100644
--- a/fuzzing/driver.c
+++ b/fuzzing/driver.c
@@ -10,6 +10,7 @@ int
main (int argc, char **argv)
{
FILE *f;
+ long tell_result;
size_t n_read, len;
unsigned char *buf;
@@ -19,7 +20,9 @@ main (int argc, char **argv)
f = fopen (argv[1], "r");
assert (f);
fseek (f, 0, SEEK_END);
- len = ftell (f);
+ tell_result = ftell (f);
+ assert (tell_result >= 0);
+ len = (size_t) tell_result;
fseek (f, 0, SEEK_SET);
buf = (unsigned char*) malloc (len);
n_read = fread (buf, 1, len, f);