Commit: 6390b530d064330edbcc50be0cdabc839f292e7c
Author: Clément Foucault
Date:   Wed Aug 5 02:25:31 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB6390b530d064330edbcc50be0cdabc839f292e7c

Fix T78529: Blend file corrupted during save caused by high Cubemap Size

This just avoid the corruption. A better fix still need to be finished.

See P1564

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

M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c

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

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 4abf37e66bc..86f1a98efa3 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6032,7 +6032,7 @@ static void 
direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTe
 
   if (lctex->data) {
     BLO_read_data_address(reader, &lctex->data);
-    if (BLO_read_requires_endian_switch(reader)) {
+    if (lctex->data && BLO_read_requires_endian_switch(reader)) {
       int data_size = lctex->components * lctex->tex_size[0] * 
lctex->tex_size[1] *
                       lctex->tex_size[2];
 
@@ -6044,6 +6044,10 @@ static void 
direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTe
       }
     }
   }
+
+  if (lctex->data == NULL) {
+    zero_v3_int(lctex->tex_size);
+  }
 }
 
 static void direct_link_lightcache(BlendDataReader *reader, LightCache *cache)
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 46ac6b43c92..0d1c3f2c3e5 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2497,7 +2497,12 @@ static void write_lightcache_texture(BlendWriter 
*writer, LightCacheTexture *tex
     else if (tex->data_type == LIGHTCACHETEX_UINT) {
       data_size *= sizeof(uint);
     }
-    BLO_write_raw(writer, data_size, tex->data);
+
+    /* FIXME: We can't save more than what 32bit systems can handle.
+     * The solution would be to split the texture but it is too late for 2.90. 
(see T78529) */
+    if (data_size < INT_MAX) {
+      BLO_write_raw(writer, data_size, tex->data);
+    }
   }
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to