Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-01-12 06:38:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-01-12 15:31:34 +0300
commite0a4b392f3888b8d792e3ab1ad7e311edd2f4c56 (patch)
tree04ecba729e03e39f8309ae8fe47bef0d7f038948
parent28b17ef0e6a82361f7061b9e074609dde9a76254 (diff)
Cleanup: use exact check for fread, move out of the loop
Without this, additional items could be added in the future which wouldn't be included in the check. Move the check out of the loop since this is such an unlikely situation that checking every iteration isn't needed. Also remove redundant casts.
-rw-r--r--source/blender/imbuf/intern/indexer.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 8233483706c..20e1febedd7 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -194,28 +194,28 @@ struct anim_index *IMB_indexer_open(const char *name)
idx->entries = MEM_callocN(sizeof(struct anim_index_entry) * idx->num_entries,
"anim_index_entries");
+ size_t items_read = 0;
for (i = 0; i < idx->num_entries; i++) {
- size_t items_read = 0;
items_read += fread(&idx->entries[i].frameno, sizeof(int), 1, fp);
items_read += fread(&idx->entries[i].seek_pos, sizeof(uint64_t), 1, fp);
items_read += fread(&idx->entries[i].seek_pos_dts, sizeof(uint64_t), 1, fp);
items_read += fread(&idx->entries[i].pts, sizeof(uint64_t), 1, fp);
+ }
- if (items_read < 4) {
- perror("error reading animation index file");
- MEM_freeN(idx->entries);
- MEM_freeN(idx);
- fclose(fp);
- return NULL;
- }
+ if (UNLIKELY(items_read != idx->num_entries * 4)) {
+ perror("error reading animation index file");
+ MEM_freeN(idx->entries);
+ MEM_freeN(idx);
+ fclose(fp);
+ return NULL;
}
if (((ENDIAN_ORDER == B_ENDIAN) != (header[8] == 'V'))) {
for (i = 0; i < idx->num_entries; i++) {
BLI_endian_switch_int32(&idx->entries[i].frameno);
- BLI_endian_switch_int64((int64_t *)&idx->entries[i].seek_pos);
- BLI_endian_switch_int64((int64_t *)&idx->entries[i].seek_pos_dts);
- BLI_endian_switch_int64((int64_t *)&idx->entries[i].pts);
+ BLI_endian_switch_uint64(&idx->entries[i].seek_pos);
+ BLI_endian_switch_uint64(&idx->entries[i].seek_pos_dts);
+ BLI_endian_switch_uint64(&idx->entries[i].pts);
}
}