Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2008-05-02 02:28:18 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2008-05-02 02:28:18 +0400
commit9ea5788c37ccd95906066a51ebcbdecc65c5f62d (patch)
tree3d70422585d4839372229cbd42da394348d059f2 /source/blender/python/api2_2x/Node.c
parentd99ddc5cf8c308bf7c0a61c1c266776a313936fa (diff)
== PyNodes ==
Bug #10104 reported by bebraw: missing check for how many node sockets were being created by a pynode script. Too many (more than MAX_SOCKET == 64) would crash Blender. http://projects.blender.org/tracker/?func=detail&atid=125&aid=10104&group_id=9 Notes: moved the MAX_SOCKET define from node.c to BKE_node.h so I could use it in Node.c. Also improved error reporting in pynodes when errors occur in the init stage. Thanks Juho (bebraw), Tom (assigned the bug to me) and Brecht (mentioned the MAX_SOCKET define).
Diffstat (limited to 'source/blender/python/api2_2x/Node.c')
-rw-r--r--source/blender/python/api2_2x/Node.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Node.c b/source/blender/python/api2_2x/Node.c
index 80b45bb2297..24df6de66cc 100644
--- a/source/blender/python/api2_2x/Node.c
+++ b/source/blender/python/api2_2x/Node.c
@@ -361,6 +361,15 @@ static int pysockets_to_blendersockets(PyObject *tuple, bNodeSocketType **socks,
len = PyTuple_Size(tuple);
+ if (len >= MAX_SOCKET) {
+ char error_msg[70];
+ PyOS_snprintf(error_msg, sizeof(error_msg),
+ "limit exceeded: each node can't have more than %d i/o sockets", MAX_SOCKET - 1);
+ PyErr_SetString(PyExc_AttributeError, error_msg);
+ len = 0;
+ retval = -1;
+ }
+
nsocks = MEM_callocN(sizeof(bNodeSocketType)*(len+1), "bNodeSocketType in Node.c");
for (pos = 0, a = 0; pos< len; pos++, a++) {
@@ -437,6 +446,7 @@ static int Map_socketdef(BPy_NodeSocketLists *self, PyObject *args, void *closur
{
bNode *node = NULL;
PyObject *tuple = NULL;
+ int ret = 0;
node = self->node;
@@ -453,7 +463,7 @@ static int Map_socketdef(BPy_NodeSocketLists *self, PyObject *args, void *closur
if (args) {
if(PySequence_Check(args)) {
tuple = PySequence_Tuple(args);
- pysockets_to_blendersockets(tuple,
+ ret = pysockets_to_blendersockets(tuple,
&(node->typeinfo->inputs), node->custom1, 1);
Py_DECREF(self->input);
self->input = tuple;
@@ -466,7 +476,7 @@ static int Map_socketdef(BPy_NodeSocketLists *self, PyObject *args, void *closur
if (args) {
if(PyList_Check(args)) {
tuple = PySequence_Tuple(args);
- pysockets_to_blendersockets(tuple,
+ ret = pysockets_to_blendersockets(tuple,
&(node->typeinfo->outputs), node->custom1, 0);
Py_DECREF(self->output);
self->output = tuple;
@@ -479,6 +489,11 @@ static int Map_socketdef(BPy_NodeSocketLists *self, PyObject *args, void *closur
fprintf(stderr,"DEBUG pynodes: got no list in Map_socketdef\n");
break;
}
+
+ if (ret == -1) {
+ node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ERROR);
+ }
+
return 0;
}