[Bf-blender-cvs] [864cb7f3768] blender-v2.82-release: Partially fix & comment about bad handling of `wrong_id` in `read_libblock()`.

Bastien Montagne noreply at git.blender.org
Tue Jan 28 16:10:08 CET 2020


Commit: 864cb7f376816ccd05e6e143dab668329b070faa
Author: Bastien Montagne
Date:   Tue Jan 28 15:46:51 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB864cb7f376816ccd05e6e143dab668329b070faa

Partially fix & comment about bad handling of `wrong_id` in `read_libblock()`.

Not fully fixing it for now since I do not see an easy way to remove freed
pointer from libmap, and it does not seem to be an actual, practical
issue currently, but eeek...

===================================================================

M	source/blender/blenloader/intern/readfile.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0ebff916cf9..f6cf68f7daf 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9315,6 +9315,9 @@ static BHead *read_libblock(FileData *fd,
   ID *id;
   ListBase *lb;
   const char *allocname;
+
+  /* XXX Very weakly handled currently, see comment at the end of this function before trying to
+   * use it for anything new. */
   bool wrong_id = false;
 
   /* In undo case, most libs and linked data should be kept as is from previous state
@@ -9570,7 +9573,14 @@ static BHead *read_libblock(FileData *fd,
   oldnewmap_clear(fd->datamap);
 
   if (wrong_id) {
+    /* XXX This is probably working OK currently given the very limited scope of that flag.
+     * However, it is absolutely **not** handled correctly: it is freeing an ID pointer that has
+     * been added to the fd->libmap mapping, which in theory could lead to nice crashes...
+     * This should be properly solved at some point. */
     BKE_id_free(main, id);
+    if (r_id != NULL) {
+      *r_id = NULL;
+    }
   }
 
   return (bhead);



More information about the Bf-blender-cvs mailing list