svn merge ^/trunk/blender -r42116:42139
[blender.git] / source / blender / blenlib / intern / pbvh.c
index ecf8fc706b95dbb96380c59ec7f02ce06a2c066b..ae0becc840b7ce63a48419aa262a7ab6f853782e 100644 (file)
@@ -656,12 +656,17 @@ void BLI_pbvh_free(PBVH *bvh)
                        /* if pbvh was deformed, new memory was allocated for verts/faces -- free it */
 
                        MEM_freeN(bvh->verts);
-                       MEM_freeN(bvh->faces);
+                       if(bvh->faces)
+                               MEM_freeN(bvh->faces);
                }
        }
 
-       MEM_freeN(bvh->nodes);
-       MEM_freeN(bvh->prim_indices);
+       if(bvh->nodes)
+               MEM_freeN(bvh->nodes);
+
+       if(bvh->prim_indices)
+               MEM_freeN(bvh->prim_indices);
+
        MEM_freeN(bvh);
 }
 
@@ -1127,6 +1132,9 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3])
        PBVHNode **nodes;
        int totnode;
 
+       if(!bvh->nodes)
+               return;
+
        BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag),
                &nodes, &totnode);