Fix error splitting convex faces
authorCampbell Barton <ideasman42@gmail.com>
Wed, 15 Jun 2016 17:43:22 +0000 (03:43 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 15 Jun 2016 17:43:22 +0000 (03:43 +1000)
Created double faces, leaked memory.

source/blender/bmesh/operators/bmo_connect_concave.c

index 34f59aad4f1124d4a4279e802c22dcaa98a20247..8b9c60ada52433ba235d022d763c9e998c2d35a1 100644 (file)
@@ -85,7 +85,7 @@ static bool bm_face_split_by_concave(
        BMFace  **faces_array = BLI_array_alloca(faces_array, faces_array_tot);
        BMEdge  **edges_array = BLI_array_alloca(edges_array, edges_array_tot);
        const int quad_method = 0, ngon_method = 0;  /* beauty */
-       LinkNode *r_faces_double = NULL;
+       LinkNode *faces_double = NULL;
 
        float normal[3];
        BLI_assert(f_base->len > 3);
@@ -96,7 +96,7 @@ static bool bm_face_split_by_concave(
                bm, f_base,
                faces_array, &faces_array_tot,
                edges_array, &edges_array_tot,
-               &r_faces_double,
+               &faces_double,
                quad_method, ngon_method, false,
                pf_arena,
                pf_heap, pf_ehash);
@@ -163,6 +163,13 @@ static bool bm_face_split_by_concave(
        BLI_heap_clear(pf_heap, NULL);
        BLI_edgehash_clear_ex(pf_ehash, NULL, BLI_POLYFILL_ALLOC_NGON_RESERVE);
 
+       while (faces_double) {
+               LinkNode *next = faces_double->next;
+               BM_face_kill(bm, faces_double->link);
+               MEM_freeN(faces_double);
+               faces_double = next;
+       }
+
        return true;
 }