Fix assert on blend file load when seek fails

Only assert seek worked as expected when it doesn't return an error.
This commit is contained in:
Campbell Barton 2023-01-09 22:03:14 +11:00
parent f3df7b4fbd
commit b5390a4aee
1 changed files with 5 additions and 3 deletions

View File

@ -724,13 +724,15 @@ static BHeadN *get_bhead(FileData *fd)
new_bhead->has_data = false;
new_bhead->is_memchunk_identical = false;
new_bhead->bhead = bhead;
off64_t seek_new = fd->file->seek(fd->file, bhead.len, SEEK_CUR);
if (seek_new == -1) {
const off64_t seek_new = fd->file->seek(fd->file, bhead.len, SEEK_CUR);
if (UNLIKELY(seek_new == -1)) {
fd->is_eof = true;
MEM_freeN(new_bhead);
new_bhead = nullptr;
}
BLI_assert(fd->file->offset == seek_new);
else {
BLI_assert(fd->file->offset == seek_new);
}
}
else {
fd->is_eof = true;