Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
multiscale
lammps
Commits
4314299b
Commit
4314299b
authored
8 years ago
by
Axel Kohlmeyer
Browse files
Options
Downloads
Patches
Plain Diff
harden fix shear/history against use-after-delete and from incorrect use of reverse communication
parent
3bb3c1a4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fix_shear_history.cpp
+13
-4
13 additions, 4 deletions
src/fix_shear_history.cpp
with
13 additions
and
4 deletions
src/fix_shear_history.cpp
+
13
−
4
View file @
4314299b
...
...
@@ -29,13 +29,13 @@
using
namespace
LAMMPS_NS
;
using
namespace
FixConst
;
enum
{
NPARTNER
,
PERPARTNER
};
enum
{
DEFAULT
,
NPARTNER
,
PERPARTNER
};
/* ---------------------------------------------------------------------- */
FixShearHistory
::
FixShearHistory
(
LAMMPS
*
lmp
,
int
narg
,
char
**
arg
)
:
Fix
(
lmp
,
narg
,
arg
),
npartner
(
NULL
),
partner
(
NULL
),
shearpartner
(
NULL
),
ipage
(
NULL
),
dpage
(
NULL
)
npartner
(
NULL
),
partner
(
NULL
),
shearpartner
(
NULL
),
pair
(
NULL
),
ipage
(
NULL
),
dpage
(
NULL
)
{
if
(
narg
!=
4
)
error
->
all
(
FLERR
,
"Illegal fix SHEAR_HISTORY commmand"
);
...
...
@@ -71,6 +71,7 @@ FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) :
maxtouch
=
0
;
nlocal_neigh
=
nall_neigh
=
0
;
commflag
=
DEFAULT
;
}
/* ---------------------------------------------------------------------- */
...
...
@@ -87,6 +88,14 @@ FixShearHistory::~FixShearHistory()
memory
->
destroy
(
npartner
);
memory
->
sfree
(
partner
);
memory
->
sfree
(
shearpartner
);
// to better detect use-after-delete errors
pair
=
NULL
;
npartner
=
NULL
;
partner
=
NULL
;
shearpartner
=
NULL
;
delete
[]
ipage
;
delete
[]
dpage
;
}
...
...
@@ -609,7 +618,7 @@ int FixShearHistory::pack_reverse_comm(int n, int first, double *buf)
m
+=
dnum
;
}
}
}
}
else
error
->
all
(
FLERR
,
"Unsupported comm mode in shear history"
);
return
m
;
}
...
...
@@ -640,7 +649,7 @@ void FixShearHistory::unpack_reverse_comm(int n, int *list, double *buf)
m
+=
dnum
;
}
}
}
}
else
error
->
all
(
FLERR
,
"Unsupported comm mode in shear history"
);
}
/* ----------------------------------------------------------------------
...
...
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