handle EOF / read errors better

This commit is contained in:
reeceal105988 committed 2026-11-08 17:12:43 +01:00
1 parent d9bb6fd600
commit cdc4a68824
1 file changed
+4 -3
+4 -3
View File
@@ -45,15 +45,16 @@ ending_openAndCheck:
static int getUShort(FILE **fd, unsigned short *bilderAnzahl)
{
if (!fread(bilderAnzahl, (size_t)sizeof(unsigned short), 1, *fd))
size_t bytes = 0;
if (!(bytes = fread(bilderAnzahl, (size_t)sizeof(unsigned short), 1, *fd)) || bytes != 1)
return 1;
return 0;
}
static int getUChar(FILE **fd, unsigned char *dest)
{
// unsigned short lab = '0';
if (!fread(dest, sizeof(*dest), 1, *fd))
size_t bytes = 0;
if (!(bytes = fread(dest, sizeof(*dest), 1, *fd)) || bytes != 1)
return 1;
// printf("Read Label: %d\n", *dest);
return 0;