Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wenqing
ogs
Commits
adc60965
Commit
adc60965
authored
6 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[MeL] MeshSubset returns no pointers.
parent
1aeaa8bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MeshLib/MeshSubset.h
+8
-4
8 additions, 4 deletions
MeshLib/MeshSubset.h
with
8 additions
and
4 deletions
MeshLib/MeshSubset.h
+
8
−
4
View file @
adc60965
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment