mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-28 13:12:10 +01:00
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
This commit is contained in:
parent
a8bc604988
commit
895da99694
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user