aboutsummaryrefslogtreecommitdiff
path: root/src/mesh.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2017-04-22 00:55:07 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-04-22 00:55:07 +0200
commit8464da75857c1556f64984c0b014300638e38d4f (patch)
tree2db32fb267c4de8093dea42032a7584067eb5ae8 /src/mesh.cpp
parent3e71c8f482131da59642b0175160eb2bc714d439 (diff)
downloadminetest-8464da75857c1556f64984c0b014300638e38d4f.tar.gz
minetest-8464da75857c1556f64984c0b014300638e38d4f.tar.bz2
minetest-8464da75857c1556f64984c0b014300638e38d4f.zip
Fix a memory leak (#5636)
Diffstat (limited to 'src/mesh.cpp')
-rw-r--r--src/mesh.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index 0a5b7fb6c..824d6891b 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -387,37 +387,39 @@ void recalculateBoundingBox(scene::IMesh *src_mesh)
scene::IMeshBuffer* cloneMeshBuffer(scene::IMeshBuffer *mesh_buffer)
{
- scene::IMeshBuffer *clone = NULL;
switch (mesh_buffer->getVertexType()) {
case video::EVT_STANDARD: {
video::S3DVertex *v = (video::S3DVertex *) mesh_buffer->getVertices();
u16 *indices = mesh_buffer->getIndices();
- scene::SMeshBuffer *temp_buf = new scene::SMeshBuffer();
- temp_buf->append(v, mesh_buffer->getVertexCount(), indices,
+ scene::SMeshBuffer *cloned_buffer = new scene::SMeshBuffer();
+ cloned_buffer->append(v, mesh_buffer->getVertexCount(), indices,
mesh_buffer->getIndexCount());
- return temp_buf;
- break;
+ return cloned_buffer;
}
case video::EVT_2TCOORDS: {
video::S3DVertex2TCoords *v =
(video::S3DVertex2TCoords *) mesh_buffer->getVertices();
u16 *indices = mesh_buffer->getIndices();
- scene::SMeshBufferTangents *temp_buf = new scene::SMeshBufferTangents();
- temp_buf->append(v, mesh_buffer->getVertexCount(), indices,
+ scene::SMeshBufferTangents *cloned_buffer =
+ new scene::SMeshBufferTangents();
+ cloned_buffer->append(v, mesh_buffer->getVertexCount(), indices,
mesh_buffer->getIndexCount());
- break;
+ return cloned_buffer;
}
case video::EVT_TANGENTS: {
video::S3DVertexTangents *v =
(video::S3DVertexTangents *) mesh_buffer->getVertices();
u16 *indices = mesh_buffer->getIndices();
- scene::SMeshBufferTangents *temp_buf = new scene::SMeshBufferTangents();
- temp_buf->append(v, mesh_buffer->getVertexCount(), indices,
+ scene::SMeshBufferTangents *cloned_buffer =
+ new scene::SMeshBufferTangents();
+ cloned_buffer->append(v, mesh_buffer->getVertexCount(), indices,
mesh_buffer->getIndexCount());
- break;
+ return cloned_buffer;
}
}
- return clone;
+ // This should not happen.
+ sanity_check(false);
+ return NULL;
}
scene::SMesh* cloneMesh(scene::IMesh *src_mesh)