forked from bartvdbraak/blender
This patch is the first of many to follow that deals with various
problems reported by klockwork.com who was very nice and has offered to provide free source code analisys for us. This one deals with freeing memory for an object when there is an error. (The function allocated memory intending to return it but then ran into problems, and was forgetting to free it before it returned NULL) Kent
This commit is contained in:
parent
9d67a597bc
commit
0360be49f5
@ -30,10 +30,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#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<BSP_MEdge>(*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<BSP_MVertex>(*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<BSP_MFace>(*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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user