[Bf-blender-cvs] [56bd7adce74] blender-v3.0-release: Fix T93858: Zstd-compressed .blend files from external tools aren't recognized

Lukas Stockner noreply at git.blender.org
Tue Jan 11 09:00:05 CET 2022


Commit: 56bd7adce74d2601d8656decf4cccb27aee4c6e4
Author: Lukas Stockner
Date:   Wed Dec 8 23:35:47 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB56bd7adce74d2601d8656decf4cccb27aee4c6e4

Fix T93858: Zstd-compressed .blend files from external tools aren't recognized

The issue here was that after the seek table check, the underlying file wasn't
rewound to the start, so the code that checks for the BLENDER header
immediately reaches EOF and fails.

Since Blender always writes files with a seek table, this bug isn't triggered
by files saved in Blender itself. However, files compressed in external tools
generally don't have a seek table.

===================================================================

M	source/blender/blenlib/intern/filereader_zstd.c

===================================================================

diff --git a/source/blender/blenlib/intern/filereader_zstd.c b/source/blender/blenlib/intern/filereader_zstd.c
index 55ce32713d9..5a04f5b11f3 100644
--- a/source/blender/blenlib/intern/filereader_zstd.c
+++ b/source/blender/blenlib/intern/filereader_zstd.c
@@ -331,5 +331,8 @@ FileReader *BLI_filereader_new_zstd(FileReader *base)
   }
   zstd->reader.close = zstd_close;
 
+  /* Rewind after the seek table check so that zstd_read starts at the file's start. */
+  zstd->base->seek(zstd->base, 0, SEEK_SET);
+
   return (FileReader *)zstd;
 }



More information about the Bf-blender-cvs mailing list