Commit: c6ea6e368b90b69b9e97aeb557b7bde6dce8f44c
Author: Campbell Barton
Date:   Sun Jun 8 22:20:03 2014 +1000
https://developer.blender.org/rBc6ea6e368b90b69b9e97aeb557b7bde6dce8f44c

BMesh: avoid recursion for BM_mesh_edgenet, runs out stack memory on large nets

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

M       source/blender/bmesh/tools/bmesh_edgenet.c

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

diff --git a/source/blender/bmesh/tools/bmesh_edgenet.c 
b/source/blender/bmesh/tools/bmesh_edgenet.c
index ddf4394..a08aa61 100644
--- a/source/blender/bmesh/tools/bmesh_edgenet.c
+++ b/source/blender/bmesh/tools/bmesh_edgenet.c
@@ -203,12 +203,18 @@ static BMEdge *bm_edgenet_path_step(
         BMVert *v_curr, LinkNode **v_ls,
         VertNetInfo *vnet_info, BLI_mempool *path_pool)
 {
-       const VertNetInfo *vn_curr = &vnet_info[BM_elem_index_get(v_curr)];
+       const VertNetInfo *vn_curr;
 
        BMEdge *e;
        BMIter iter;
-       unsigned int tot = 0;
-       unsigned int v_ls_tot = 0;
+       unsigned int tot;
+       unsigned int v_ls_tot;
+
+
+begin:
+       tot = 0;
+       v_ls_tot = 0;
+       vn_curr = &vnet_info[BM_elem_index_get(v_curr)];
 
        BM_ITER_ELEM (e, &iter, v_curr, BM_EDGES_OF_VERT) {
                BMVert *v_next = BM_edge_other_vert(e, v_curr);
@@ -256,7 +262,12 @@ static BMEdge *bm_edgenet_path_step(
        /* trick to walk along wire-edge paths */
        if (v_ls_tot == 1 && tot == 1) {
                v_curr = BLI_linklist_pop_pool(v_ls, path_pool);
+               /* avoid recursion, can crash on very large nets */
+#if 0
                bm_edgenet_path_step(v_curr, v_ls, vnet_info, path_pool);
+#else
+               goto begin;
+#endif
        }
 
        return NULL;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to