Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-06 19:02:22 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-06 19:39:33 +0300
commitc0432c2385e655563cc9cfeec6e97f531d0b1f24 (patch)
treeb0b37a141ff9264ce5eabc24b39ca15f9c047969 /source/blender/blenloader
parent1854cccad7c31a6b8235faf980ffdd6a80163e02 (diff)
Fix T63046, T61413: crash reading paint slots from 32 bit .blend on 64 bit
Thanks to matc for helping to find this, it was writing the paint slots wrong.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c7
-rw-r--r--source/blender/blenloader/intern/writefile.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 78c5bdbed1d..ae4644f2950 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6624,6 +6624,13 @@ static void direct_link_paint(FileData *fd, const Scene *scene, Paint *p)
p->tool_slots = newdataadr(fd, p->tool_slots);
+ /* Workaround for invalid data written in older versions. */
+ const size_t expected_size = sizeof(PaintToolSlot) * p->tool_slots_len;
+ if (p->tool_slots && MEM_allocN_len(p->tool_slots) < expected_size) {
+ MEM_freeN(p->tool_slots);
+ p->tool_slots = MEM_callocN(expected_size, "PaintToolSlot");
+ }
+
BKE_paint_runtime_init(scene->toolsettings, p);
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 9a4e2adc0e3..6305aa95e7f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2416,7 +2416,7 @@ static void write_paint(WriteData *wd, Paint *p)
if (p->cavity_curve) {
write_curvemapping(wd, p->cavity_curve);
}
- writedata(wd, DATA, sizeof(PaintToolSlot) * p->tool_slots_len, p->tool_slots);
+ writestruct(wd, DATA, PaintToolSlot, p->tool_slots_len, p->tool_slots);
}
static void write_layer_collections(WriteData *wd, ListBase *lb)