diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-08 19:01:18 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-08 19:53:31 +0300 |
commit | 13978f7ff6819e255601f5e5c42d540472c18afb (patch) | |
tree | 4ec7683b97d6b9dddd7f4e37abce7749fd13c935 | |
parent | 18d470e5e44dae79bd571b604d03e7bda92aa501 (diff) |
Followup to T62318: Fix on-the-fly that kind of .blend file cddata corruption.
Remove cddata layers which are not supposed to be written in .blend file,
when reading it.
This is a cheap and simple check, which also gives us forward compatibility
in case we decide some day to make a currently un-written layer type
to be written in .blend files.
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index fbea4ecc01e..56847aded8b 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -3641,6 +3641,19 @@ bool CustomData_verify_versions(struct CustomData *data, int index) { keeplayer = false; /* multiple layers of which we only support one */ } + /* This is a pre-emptive fix for cases that should not happen (layers that should not be written + * in .blend files), but can happen due to bugs (see e.g. T62318). + * Also for forward compatibility, in future, we may put into .blend file some currently un-written data types, + * this should cover that case as well. + * Better to be safe here, and fix issue on the fly rather than crash... */ + /* 0 structnum is used in writing code to tag layer types that should not be written. */ + else if (typeInfo->structnum == 0 && + /* XXX Not sure why those two are exception, maybe that should be fixed? */ + !ELEM(layer->type, CD_PAINT_MASK, CD_FACEMAP)) + { + keeplayer = false; + CLOG_WARN(&LOG, ".blend file read: removing a data layer that should not have been written"); + } } if (!keeplayer) { |