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
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-06-10 17:31:41 +0300
committerJacques Lucke <jacques@blender.org>2020-06-10 17:31:41 +0300
commit3ea04d3e11e0b1b26ff55890f20314648b5e2f08 (patch)
tree821e04e95b7495f549508d2fb896561f7cae6aa6 /source
parent6fe32d7fd689279eb5517e8fe776545f460df051 (diff)
Blenloader: Don't just crash when a struct name is not known
Related to T77524. This brings back the old way of handling corrupted data.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/writefile.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 3094e810c28..a3102200411 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -4548,8 +4548,7 @@ void BLO_write_raw(BlendWriter *writer, int size_in_bytes, const void *data_ptr)
void BLO_write_struct_by_name(BlendWriter *writer, const char *struct_name, const void *data_ptr)
{
- int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
- BLO_write_struct_by_id(writer, struct_id, data_ptr);
+ BLO_write_struct_array_by_name(writer, struct_name, 1, data_ptr);
}
void BLO_write_struct_array_by_name(BlendWriter *writer,
@@ -4558,6 +4557,10 @@ void BLO_write_struct_array_by_name(BlendWriter *writer,
const void *data_ptr)
{
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
+ if (UNLIKELY(struct_id == -1)) {
+ printf("error: can't find SDNA code <%s>\n", struct_name);
+ return;
+ }
BLO_write_struct_array_by_id(writer, struct_id, array_size, data_ptr);
}
@@ -4595,7 +4598,12 @@ void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, ListBase *l
void BLO_write_struct_list_by_name(BlendWriter *writer, const char *struct_name, ListBase *list)
{
- BLO_write_struct_list_by_id(writer, BLO_get_struct_id_by_name(writer, struct_name), list);
+ int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
+ if (UNLIKELY(struct_id == -1)) {
+ printf("error: can't find SDNA code <%s>\n", struct_name);
+ return;
+ }
+ BLO_write_struct_list_by_id(writer, struct_id, list);
}
void blo_write_id_struct(BlendWriter *writer, int struct_id, const void *id_address, const ID *id)
@@ -4606,7 +4614,6 @@ void blo_write_id_struct(BlendWriter *writer, int struct_id, const void *id_addr
int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name)
{
int struct_id = DNA_struct_find_nr(writer->wd->sdna, struct_name);
- BLI_assert(struct_id >= 0);
return struct_id;
}