diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-11-01 06:27:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-01 06:27:25 +0300 |
commit | 99df433ea76c5b4b0009944e902ef7bd4166a17f (patch) | |
tree | 538f89a5e4d003486eed7792a21bbd170ba85184 /source/blender | |
parent | 632ed6a0d6795831ef94a4b5053fb883a57e7198 (diff) |
Fix T46655: crash reading unknown ID types
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d6ba79f5a98..92925eeb425 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7908,23 +7908,28 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID /* read libblock */ id = read_struct(fd, bhead, "lib block"); + + if (id) { + const short idcode = (bhead->code == ID_ID) ? GS(id->name) : bhead->code; + /* do after read_struct, for dna reconstruct */ + lb = which_libbase(main, idcode); + if (lb) { + oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); /* for ID_ID check */ + BLI_addtail(lb, id); + } + else { + /* unknown ID type */ + printf("%s: unknown id code '%c%c'\n", __func__, (idcode & 0xff), (idcode >> 8)); + MEM_freeN(id); + id = NULL; + } + } + if (r_id) *r_id = id; if (!id) return blo_nextbhead(fd, bhead); - oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); /* for ID_ID check */ - - /* do after read_struct, for dna reconstruct */ - if (bhead->code == ID_ID) { - lb = which_libbase(main, GS(id->name)); - } - else { - lb = which_libbase(main, bhead->code); - } - - BLI_addtail(lb, id); - /* clear first 8 bits */ id->flag = (id->flag & 0xFF00) | flag | LIB_NEED_LINK; id->lib = main->curlib; |