[Bf-blender-cvs] [ffb220590ea] blender-v2.83-release: Fix T81226: Crash opening 64bit files with endian switching

Campbell Barton noreply at git.blender.org
Wed Oct 28 09:55:52 CET 2020


Commit: ffb220590ea76bc279eeb3498776a360467125c1
Author: Campbell Barton
Date:   Wed Oct 7 21:48:59 2020 +1100
Branches: blender-v2.83-release
https://developer.blender.org/rBffb220590ea76bc279eeb3498776a360467125c1

Fix T81226: Crash opening 64bit files with endian switching

Endian switching when loading 64bit blend files on a 64bit system was
crashing as the endian switching is only applicable when loading
on 32 bit systems.

This crash goes back to 2.7x, it looks like this never worked
all the way back to the first commit.

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

M	source/blender/makesdna/intern/dna_genfile.c

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

diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index cf7c201795e..5ee48641d5b 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -1356,8 +1356,12 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
     else {
       /* non-struct field type */
       if (ispointer(name)) {
-        if (oldsdna->pointer_size == 8) {
-          BLI_endian_switch_int64_array((int64_t *)cur, old_name_array_len);
+        /* See readfile.c (#bh4_from_bh8 swap endian argument),
+         * this is only done when reducing the size of a pointer from 4 to 8. */
+        if (sizeof(void *) < 8) {
+          if (oldsdna->pointer_size == 8) {
+            BLI_endian_switch_int64_array((int64_t *)cur, old_name_array_len);
+          }
         }
       }
       else {



More information about the Bf-blender-cvs mailing list