Commit: 70d78635003c2b4c12be4abd3ccada5d30cf1ac1
Author: Campbell Barton
Date:   Thu Oct 22 15:26:22 2020 +1100
Branches: blender-v2.83-release
https://developer.blender.org/rB70d78635003c2b4c12be4abd3ccada5d30cf1ac1

Fix T81939: crash calling bmesh.utils.vert_separate()

Missing NULL check in bmesh_kernel_vert_separate.

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

M       source/blender/bmesh/intern/bmesh_core.c

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

diff --git a/source/blender/bmesh/intern/bmesh_core.c 
b/source/blender/bmesh/intern/bmesh_core.c
index 8f55c14c681..1d063be4b48 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -2335,45 +2335,44 @@ void bmesh_kernel_vert_separate(
       BLI_assert(!BM_ELEM_API_FLAG_TEST(e_iter, EDGE_VISIT));
       BM_ELEM_API_FLAG_ENABLE(e_iter, EDGE_VISIT);
     } while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
-  }
 
-  while (true) {
-    /* Considering only edges and faces incident on vertex v, walk
-     * the edges & collect in the 'edges' list for splitting */
+    while (true) {
+      /* Considering only edges and faces incident on vertex v, walk
+       * the edges & collect in the 'edges' list for splitting */
 
-    BMEdge *e = v->e;
-    BM_ELEM_API_FLAG_DISABLE(e, EDGE_VISIT);
+      BMEdge *e = v->e;
+      BM_ELEM_API_FLAG_DISABLE(e, EDGE_VISIT);
 
-    do {
-      BLI_assert(!BM_ELEM_API_FLAG_TEST(e, EDGE_VISIT));
-      BLI_SMALLSTACK_PUSH(edges, e);
-      edges_found += 1;
+      do {
+        BLI_assert(!BM_ELEM_API_FLAG_TEST(e, EDGE_VISIT));
+        BLI_SMALLSTACK_PUSH(edges, e);
+        edges_found += 1;
+
+        if (e->l) {
+          BMLoop *l_iter, *l_first;
+          l_iter = l_first = e->l;
+          do {
+            BMLoop *l_adjacent = (l_iter->v == v) ? l_iter->prev : 
l_iter->next;
+            BLI_assert(BM_vert_in_edge(l_adjacent->e, v));
+            if (BM_ELEM_API_FLAG_TEST(l_adjacent->e, EDGE_VISIT)) {
+              BM_ELEM_API_FLAG_DISABLE(l_adjacent->e, EDGE_VISIT);
+              BLI_SMALLSTACK_PUSH(edges_search, l_adjacent->e);
+            }
+          } while ((l_iter = l_iter->radial_next) != l_first);
+        }
+      } while ((e = BLI_SMALLSTACK_POP(edges_search)));
 
-      if (e->l) {
-        BMLoop *l_iter, *l_first;
-        l_iter = l_first = e->l;
-        do {
-          BMLoop *l_adjacent = (l_iter->v == v) ? l_iter->prev : l_iter->next;
-          BLI_assert(BM_vert_in_edge(l_adjacent->e, v));
-          if (BM_ELEM_API_FLAG_TEST(l_adjacent->e, EDGE_VISIT)) {
-            BM_ELEM_API_FLAG_DISABLE(l_adjacent->e, EDGE_VISIT);
-            BLI_SMALLSTACK_PUSH(edges_search, l_adjacent->e);
-          }
-        } while ((l_iter = l_iter->radial_next) != l_first);
-      }
-    } while ((e = BLI_SMALLSTACK_POP(edges_search)));
+      /* now we have all edges connected to 'v->e' */
 
-    /* now we have all edges connected to 'v->e' */
+      BLI_assert(edges_found <= v_edges_num);
 
-    BLI_assert(edges_found <= v_edges_num);
+      if (edges_found == v_edges_num) {
+        /* We're done! The remaining edges in 'edges' form the last fan,
+         * which can be left as is.
+         * if 'edges' were alloc'd it'd be freed here. */
+        break;
+      }
 
-    if (edges_found == v_edges_num) {
-      /* We're done! The remaining edges in 'edges' form the last fan,
-       * which can be left as is.
-       * if 'edges' were alloc'd it'd be freed here. */
-      break;
-    }
-    else {
       BMVert *v_new;
 
       v_new = BM_vert_create(bm, v->co, v, BM_CREATE_NOP);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to