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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder_nodes.cc')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 01d84f6b5d8..c512300200e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -319,6 +319,18 @@ void DepsgraphNodeBuilder::begin_build()
* them for new ID nodes. */
id_info_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
for (IDNode *id_node : graph_->id_nodes) {
+ /* It is possible that the ID does not need to have CoW version in which case id_cow is the
+ * same as id_orig. Additionally, such ID might have been removed, which makes the check
+ * for whether id_cow is expanded to access freed memory. In orderr to deal with this we
+ * check whether CoW is needed based on a scalar value which does not lead to access of
+ * possibly deleted memory.
+ * Additionally, this saves some space in the map by skipping mapping for datablocks which
+ * do not need CoW, */
+ if (!deg_copy_on_write_is_needed(id_node->id_type)) {
+ id_node->id_cow = nullptr;
+ continue;
+ }
+
IDInfo *id_info = (IDInfo *)MEM_mallocN(sizeof(IDInfo), "depsgraph id info");
if (deg_copy_on_write_is_expanded(id_node->id_cow) && id_node->id_orig != id_node->id_cow) {
id_info->id_cow = id_node->id_cow;