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.
This commit is contained in:
Campbell Barton 2020-10-07 21:48:59 +11:00 committed by Jeroen Bakker
parent 6b1042f45a
commit ffb220590e
Notes: blender-bot 2023-02-14 06:55:40 +01:00
Referenced by issue #81226, OldNewMap handling of pointers in blenloader does not work correctly with FD_FLAGS_SWITCH_ENDIAN
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 6 additions and 2 deletions

View File

@ -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 {