[Bf-blender-cvs] [99df433] master: Fix T46655: crash reading unknown ID types
Campbell Barton
noreply at git.blender.org
Sun Nov 1 04:34:33 CET 2015
Commit: 99df433ea76c5b4b0009944e902ef7bd4166a17f
Author: Campbell Barton
Date: Sun Nov 1 14:27:25 2015 +1100
Branches: master
https://developer.blender.org/rB99df433ea76c5b4b0009944e902ef7bd4166a17f
Fix T46655: crash reading unknown ID types
===================================================================
M source/blender/blenloader/intern/readfile.c
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index d6ba79f..92925ee 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;
More information about the Bf-blender-cvs
mailing list