[Bf-blender-cvs] [c0b717b] master: Sanity check in node links API: Make sure a valid node exists for both sockets passed to the nodetree.links.new function, otherwise this could lead to invalid connections between different node trees! The ntreeAddLink function has asserts for this, but this condition needs to be checked in the RNA method calling it.

Lukas Tönne noreply at git.blender.org
Wed Dec 11 09:26:04 CET 2013


Commit: c0b717b046804022bd0c3b45ffadf285746563ee
Author: Lukas Tönne
Date:   Wed Dec 11 09:20:08 2013 +0100
http://developer.blender.org/rBc0b717b046804022bd0c3b45ffadf285746563ee

Sanity check in node links API: Make sure a valid node exists for both
sockets passed to the nodetree.links.new function, otherwise this could
lead to invalid connections between different node trees! The
ntreeAddLink function has asserts for this, but this condition needs to
be checked in the RNA method calling it.

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

M	source/blender/makesrna/intern/rna_nodetree.c

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

diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 44334ce..55989bd 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -793,6 +793,11 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports,
 
 	nodeFindNode(ntree, fromsock, &fromnode, NULL);
 	nodeFindNode(ntree, tosock, &tonode, NULL);
+	/* check validity of the sockets:
+	 * if sockets from different trees are passed in this will fail!
+	 */
+	if (!fromnode || !tonode)
+		return NULL;
 	
 	if (&fromsock->in_out == &tosock->in_out) {
 		BKE_report(reports, RPT_ERROR, "Same input/output direction of sockets");




More information about the Bf-blender-cvs mailing list