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:
authorCampbell Barton <ideasman42@gmail.com>2020-10-22 07:26:22 +0300
committerJeroen Bakker <jeroen@blender.org>2020-10-28 11:25:42 +0300
commit70d78635003c2b4c12be4abd3ccada5d30cf1ac1 (patch)
tree55ec898f3e0adf595c7d9ef89b33b81eeb502d41
parent05b4d8d13a9ca3691c7aa8f2ceebd8155bd31fa7 (diff)
Fix T81939: crash calling bmesh.utils.vert_separate()
Missing NULL check in bmesh_kernel_vert_separate.
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c63
1 files changed, 31 insertions, 32 deletions
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);