diff --git a/caff.c b/caff.c index c30b8c1..da34022 100644 --- a/caff.c +++ b/caff.c @@ -61,8 +61,16 @@ CAFF *caff_parse_file(const char *filename) { uint8_t id; uint64_t length; - fread(&id, sizeof(uint8_t), 1, file); - fread(&length, sizeof(uint64_t), 1, file); + if(fread(&id, sizeof(uint8_t), 1, file) != 1 || + fread(&length, sizeof(uint64_t), 1, file) != 1){ + printf("Failed to read block id/length!\n"); + fclose(file); + if(anim_count == 0){ + free(caff); + caff = NULL; + } + return caff; + } switch (id) { diff --git a/test.c b/test.c index b9cce3b..7b9dfb3 100644 --- a/test.c +++ b/test.c @@ -1,7 +1,7 @@ #include #include -#define TEST_COUNT 8 +#define TEST_COUNT 9 #define COMMAND_SIZE 128 int main(void) diff --git a/test_cases/9.caff b/test_cases/9.caff new file mode 100644 index 0000000..e69de29