diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2017-02-17 05:41:38 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2017-02-17 05:41:38 +0300 |
commit | d41451a0ca5053885deffce2bf603fc6c488ddf4 (patch) | |
tree | 8a0e9941fa468f4246e375e7c98751d7952d53d1 /source | |
parent | 6c59a3b37aa868c74ba403a7be297174053ff48c (diff) |
Forgotten in last commit: Check the allocation
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/bvhutils.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index fbb2aba4549..5a0006e679f 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -587,7 +587,9 @@ BVHTree *bvhtree_from_mesh_verts( data, tree, true, epsilon, vert, vert_allocated); } else { - MEM_freeN(vert); + if (vert_allocated) { + MEM_freeN(vert); + } memset(data, 0, sizeof(*data)); } return tree; @@ -792,8 +794,12 @@ BVHTree *bvhtree_from_mesh_edges( data, tree, true, epsilon, vert, vert_allocated, edge, edge_allocated); } else { - MEM_freeN(vert); - MEM_freeN(edge); + if (vert_allocated) { + MEM_freeN(vert); + } + if (edge_allocated) { + MEM_freeN(edge); + } memset(data, 0, sizeof(*data)); } return tree; @@ -943,8 +949,12 @@ BVHTree *bvhtree_from_mesh_faces( data, tree, true, epsilon, vert, vert_allocated, face, face_allocated); } else { - MEM_freeN(vert); - MEM_freeN(face); + if (vert_allocated) { + MEM_freeN(vert); + } + if (face_allocated) { + MEM_freeN(face); + } memset(data, 0, sizeof(*data)); } return tree; |