diff --git a/intern/bsp/intern/BSP_CSGMesh.cpp b/intern/bsp/intern/BSP_CSGMesh.cpp index 73db00b17a1..36f00868240 100755 --- a/intern/bsp/intern/BSP_CSGMesh.cpp +++ b/intern/bsp/intern/BSP_CSGMesh.cpp @@ -30,10 +30,6 @@ */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include "BSP_CSGMesh.h" #include "MT_assert.h" #include "CTR_TaggedSetOps.h" @@ -78,23 +74,39 @@ NewCopy( if (m_edges != NULL) { mesh->m_edges = new vector(*m_edges); - if (mesh->m_edges == NULL) return NULL; + if (mesh->m_edges == NULL) { + delete mesh; + return NULL; + } } if (m_verts != NULL) { mesh->m_verts = new vector(*m_verts); - if (mesh->m_verts == NULL) return NULL; + if (mesh->m_verts == NULL) { + if (m_edges != NULL) free(mesh->m_edges); + delete mesh; + return NULL; + } } if (m_faces != NULL) { mesh->m_faces = new vector(*m_faces); - if (mesh->m_faces == NULL) return NULL; + if (mesh->m_faces == NULL) { + delete mesh; + return NULL; + } } if (m_fv_data != NULL) { mesh->m_fv_data = new BSP_CSGUserData(*m_fv_data); - if (mesh->m_fv_data == NULL) return NULL; + if (mesh->m_fv_data == NULL) { + delete mesh; + return NULL; + } } if (m_face_data != NULL) { mesh->m_face_data = new BSP_CSGUserData(*m_face_data); - if (mesh->m_face_data == NULL) return NULL; + if (mesh->m_face_data == NULL) { + delete mesh; + return NULL; + } } return mesh; @@ -889,5 +901,3 @@ CountTriangles( return sum; } - -