Fix for #28980, could enter infinite loop during node socket verification if dynamic...
authorLukas Toenne <lukas.toenne@googlemail.com>
Thu, 20 Oct 2011 10:36:02 +0000 (10:36 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Thu, 20 Oct 2011 10:36:02 +0000 (10:36 +0000)
Note: in this particular bug report the sockets have some faulty flag settings (none of them should be flagged as SOCK_DYNAMIC), needs more info.

source/blender/nodes/intern/node_socket.c

index 51e48b84383193b9d1020da4c54c2c778763f45d..74f15af88a2c9230fc3a6785ce9dd30765a085a8 100644 (file)
@@ -405,15 +405,15 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in
 
 static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_out, ListBase *socklist, bNodeSocketTemplate *stemp_first)
 {
 
 static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_out, ListBase *socklist, bNodeSocketTemplate *stemp_first)
 {
-       bNodeSocket *sock;
+       bNodeSocket *sock, *nextsock;
        bNodeSocketTemplate *stemp;
        
        /* no inputs anymore? */
        if(stemp_first==NULL) {
        bNodeSocketTemplate *stemp;
        
        /* no inputs anymore? */
        if(stemp_first==NULL) {
-               while(socklist->first) {
-                       sock = (bNodeSocket*)socklist->first;
+               for (sock = (bNodeSocket*)socklist->first; sock; sock=nextsock) {
+                       nextsock = sock->next;
                        if (!(sock->flag & SOCK_DYNAMIC))
                        if (!(sock->flag & SOCK_DYNAMIC))
-                               nodeRemoveSocket(ntree, node, socklist->first);
+                               nodeRemoveSocket(ntree, node, sock);
                }
        }
        else {
                }
        }
        else {
@@ -424,10 +424,10 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou
                        stemp++;
                }
                /* leftovers are removed */
                        stemp++;
                }
                /* leftovers are removed */
-               while(socklist->first) {
-                       sock = (bNodeSocket*)socklist->first;
+               for (sock = (bNodeSocket*)socklist->first; sock; sock=nextsock) {
+                       nextsock = sock->next;
                        if (!(sock->flag & SOCK_DYNAMIC))
                        if (!(sock->flag & SOCK_DYNAMIC))
-                               nodeRemoveSocket(ntree, node, socklist->first);
+                               nodeRemoveSocket(ntree, node, sock);
                }
                
                /* and we put back the verified sockets */
                }
                
                /* and we put back the verified sockets */