[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50013] branches/soc-2011-tomato/intern/ cycles/render/graph.cpp: Tomato Cycles: fix for reading freed memory

Sergey Sharybin sergey.vfx at gmail.com
Sun Aug 19 14:07:29 CEST 2012


Revision: 50013
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50013
Author:   nazgul
Date:     2012-08-19 12:07:28 +0000 (Sun, 19 Aug 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/cycles/render/graph.cpp

Modified: branches/soc-2011-tomato/intern/cycles/render/graph.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/render/graph.cpp	2012-08-19 11:51:58 UTC (rev 50012)
+++ branches/soc-2011-tomato/intern/cycles/render/graph.cpp	2012-08-19 12:07:28 UTC (rev 50013)
@@ -402,6 +402,20 @@
 	/* 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])




More information about the Bf-blender-cvs mailing list