Unverified Commit b37e55be authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2714 from thtrummer/master

Fix undefined behaviour when accessing empty std::vector
parents 323159d8 573cd35f
......@@ -41,7 +41,7 @@ CpuBondForce::CpuBondForce() {
void CpuBondForce::initialize(int numAtoms, int numBonds, int numAtomsPerBond, vector<vector<int> >& bondAtoms, ThreadPool& threads) {
this->numBonds = numBonds;
this->numAtomsPerBond = numAtomsPerBond;
this->bondAtoms = &bondAtoms[0];
this->bondAtoms = bondAtoms.empty() ? nullptr : bondAtoms.data();
this->threads = &threads;
int numThreads = threads.getNumThreads();
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