Skip to content
Snippets Groups Projects
Commit adc60965 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MeL] MeshSubset returns no pointers.

parent 1aeaa8bc
No related branches found
No related tags found
No related merge requests found
......@@ -134,13 +134,12 @@ public:
/// nodes and the provided vector of nodes.
/// An empty mesh subset may be returned, not a nullptr, in case of empty
/// intersection or empty input vector.
MeshSubset*
getIntersectionByNodes(std::vector<Node*> const& nodes) const
MeshSubset getIntersectionByNodes(std::vector<Node*> const& nodes) const
{
auto* active_nodes = new std::vector<Node*>;
if (_nodes == nullptr || _nodes->empty())
return new MeshSubset(_msh, active_nodes); // Empty mesh subset
return MeshSubset(_msh, active_nodes); // Empty mesh subset
for (auto n : nodes)
{
......@@ -152,7 +151,12 @@ public:
// Transfer the ownership of active_nodes to the new MeshSubset, which
// deletes the pointer itself.
return new MeshSubset(_msh, active_nodes, true);
return MeshSubset(_msh, active_nodes,
false); // This causes a memory leak of the non
// deleted active_nodes vector.
// Calling ctor with 'true', causes double
// free of the nodes vector, when MS is
// copied multiple times.
}
Mesh const& getMesh() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment