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.
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user