Commit 573cd35f authored by Thomas Trummer's avatar Thomas Trummer
Browse files

Fix undefined behaviour when accessing empty std::vector

parent 323159d8
...@@ -41,7 +41,7 @@ CpuBondForce::CpuBondForce() { ...@@ -41,7 +41,7 @@ CpuBondForce::CpuBondForce() {
void CpuBondForce::initialize(int numAtoms, int numBonds, int numAtomsPerBond, vector<vector<int> >& bondAtoms, ThreadPool& threads) { void CpuBondForce::initialize(int numAtoms, int numBonds, int numAtomsPerBond, vector<vector<int> >& bondAtoms, ThreadPool& threads) {
this->numBonds = numBonds; this->numBonds = numBonds;
this->numAtomsPerBond = numAtomsPerBond; this->numAtomsPerBond = numAtomsPerBond;
this->bondAtoms = &bondAtoms[0]; this->bondAtoms = bondAtoms.empty() ? nullptr : bondAtoms.data();
this->threads = &threads; this->threads = &threads;
int numThreads = threads.getNumThreads(); int numThreads = threads.getNumThreads();
int targetBondsPerThread = numBonds/numThreads; int targetBondsPerThread = numBonds/numThreads;
......
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