Commit 040890d5 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1526 from peastman/indexcheck

Added check for illegal particle index
parents 4278a19d de44acd9
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2014 Stanford University and the Authors. * * Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -195,6 +195,9 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p ...@@ -195,6 +195,9 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
void CustomNonbondedForce::createExclusionsFromBonds(const vector<pair<int, int> >& bonds, int bondCutoff) { void CustomNonbondedForce::createExclusionsFromBonds(const vector<pair<int, int> >& bonds, int bondCutoff) {
if (bondCutoff < 1) if (bondCutoff < 1)
return; return;
for (int i = 0; i < (int) bonds.size(); ++i)
if (bonds[i].first < 0 || bonds[i].second < 0 || bonds[i].first >= particles.size() || bonds[i].second >= particles.size())
throw OpenMMException("createExclusionsFromBonds: Illegal particle index in list of bonds");
vector<set<int> > exclusions(particles.size()); vector<set<int> > exclusions(particles.size());
vector<set<int> > bonded12(exclusions.size()); vector<set<int> > bonded12(exclusions.size());
for (int i = 0; i < (int) bonds.size(); ++i) { for (int i = 0; i < (int) bonds.size(); ++i) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2014 Stanford University and the Authors. * * Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -184,6 +184,9 @@ ForceImpl* NonbondedForce::createImpl() const { ...@@ -184,6 +184,9 @@ ForceImpl* NonbondedForce::createImpl() const {
} }
void NonbondedForce::createExceptionsFromBonds(const vector<pair<int, int> >& bonds, double coulomb14Scale, double lj14Scale) { void NonbondedForce::createExceptionsFromBonds(const vector<pair<int, int> >& bonds, double coulomb14Scale, double lj14Scale) {
for (int i = 0; i < (int) bonds.size(); ++i)
if (bonds[i].first < 0 || bonds[i].second < 0 || bonds[i].first >= particles.size() || bonds[i].second >= particles.size())
throw OpenMMException("createExceptionsFromBonds: Illegal particle index in list of bonds");
// Find particles separated by 1, 2, or 3 bonds. // Find particles separated by 1, 2, or 3 bonds.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment