Tomato Cycles: fix for reading freed memory
Incorrect read was happening after nodes which are not affect on output were removed from the graph. Other nodes could have been connected to this nodes which lead to accessing freed memory in some other places. Solved by removing links from unused nodes before removing them from the graph.
This commit is contained in:
@@ -402,6 +402,20 @@ void ShaderGraph::clean()
|
||||
/* break cycles */
|
||||
break_cycles(output(), visited, on_stack);
|
||||
|
||||
/* disconnect unused nodes */
|
||||
foreach(ShaderNode *node, nodes) {
|
||||
if(!visited[node->id]) {
|
||||
foreach(ShaderInput *to, node->inputs) {
|
||||
ShaderOutput *from = to->link;
|
||||
|
||||
if (from) {
|
||||
to->link = NULL;
|
||||
from->links.erase(remove(from->links.begin(), from->links.end(), to), from->links.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* remove unused nodes */
|
||||
foreach(ShaderNode *node, nodes) {
|
||||
if(visited[node->id])
|
||||
|
||||
Reference in New Issue
Block a user