Skip to content

Commit

Permalink
tweak get_crc32 function
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed Sep 23, 2024
1 parent db9cfb8 commit 7febf01
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,14 @@ unsigned long util_get_crc32(char* filename)
if (fp)
{
char buf[1024];
for (size_t s = 0; (s = fread(buf, 1, sizeof(buf), fp));)
for (size_t s = 0; (s = fread(buf, 1, sizeof(buf), fp)) && !ferror(fp);)
{
if (ferror(fp))
{
crc32 = 0;
break;
}

crc32 = Crc32_ComputeBuf(crc32, buf, s);
}

if (ferror(fp))
crc32 = 0;

fclose(fp);
}

Expand Down

0 comments on commit 7febf01

Please sign in to comment.