1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

tweak get_crc32 function

This commit is contained in:
FunkyFr3sh 2024-09-23 15:35:13 +02:00
parent db9cfb8e29
commit 7febf01343

View File

@ -118,17 +118,14 @@ unsigned long util_get_crc32(char* filename)
if (fp) if (fp)
{ {
char buf[1024]; 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); crc32 = Crc32_ComputeBuf(crc32, buf, s);
} }
if (ferror(fp))
crc32 = 0;
fclose(fp); fclose(fp);
} }