Fix for crash when duplicating image or render layer nodes.
authorLukas Toenne <lukas.toenne@googlemail.com>
Wed, 7 Sep 2011 12:46:30 +0000 (12:46 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Wed, 7 Sep 2011 12:46:30 +0000 (12:46 +0000)
These nodes use cached buffers (in sock->cache), which need to be cleared when duplicating the node, otherwise the buffer will be freed twice.

source/blender/blenkernel/intern/node.c
source/blender/nodes/composite/node_composite_tree.c

index 292f38b9472bd3d8e14f8796671c3c30cb2561fd..d40b030c4704a3e19616eb3bb5c893f77f0c1dfc 100644 (file)
@@ -398,6 +398,11 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
                sock->stack_index= 0;
                
                sock->default_value = (oldsock->default_value ? MEM_dupallocN(oldsock->default_value) : NULL);
+               
+               /* XXX some compositor node (e.g. image, render layers) still store
+                * some persistent buffer data here, need to clear this to avoid dangling pointers.
+                */
+               sock->cache = NULL;
        }
        
        BLI_duplicatelist(&nnode->outputs, &node->outputs);
@@ -407,6 +412,11 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
                sock->stack_index= 0;
                
                sock->default_value = (oldsock->default_value ? MEM_dupallocN(oldsock->default_value) : NULL);
+               
+               /* XXX some compositor node (e.g. image, render layers) still store
+                * some persistent buffer data here, need to clear this to avoid dangling pointers.
+                */
+               sock->cache = NULL;
        }
        
        /* don't increase node->id users, freenode doesn't decrement either */
index 9593e61beb68bf0caafdaffee0c9c6d793e9756f..01e46ed3df93b4900f3beacc8bce6be1edb5f9f6 100644 (file)
@@ -362,7 +362,7 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd)
                int a;
                node = nodeexec->node;
                
-               node_get_stack(node, thd->stack, nsin, nsout);
+               node_get_stack(node, exec->stack, nsin, nsout);
                
                /* test the outputs */
                /* skip value-only nodes (should be in type!) */
@@ -428,7 +428,7 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd)
                        node = nodeexec->node;
                        if(node->need_exec==0 && node_only_value(node)) {
                                if(node->typeinfo->execfunc) {
-                                       node_get_stack(node, thd->stack, nsin, nsout);
+                                       node_get_stack(node, exec->stack, nsin, nsout);
                                        node->typeinfo->execfunc(thd->rd, node, nsin, nsout);
                                }
                        }