Skip to content

Commit

Permalink
Check the return value of fseek.
Browse files Browse the repository at this point in the history
  • Loading branch information
redcode committed Mar 6, 2024
1 parent 5a1a2a7 commit 20b8781
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions sources/test-Z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,12 @@ static zboolean load_file(

if (file != Z_NULL)
{
fseek(file, 0, SEEK_END);

if (ftell(file) == file_size)
{
fseek(file, offset, SEEK_SET);
ok = fread(buffer, size, 1, file) == 1;
}
if ( !fseek(file, 0, SEEK_END) &&
ftell(file) == file_size &&
!fseek(file, offset, SEEK_SET) &&
fread(buffer, size, 1, file) == 1
)
ok = Z_TRUE;

fclose(file);
}
Expand Down

0 comments on commit 20b8781

Please sign in to comment.