Skip to content
Snippets Groups Projects
Commit c99ef0bb authored by cmaffeo2's avatar cmaffeo2
Browse files

Fixed probable bug in memory allocation of bonds array

parent 192408a5
No related branches found
No related tags found
No related merge requests found
...@@ -1059,7 +1059,7 @@ void Configuration::readBonds() { ...@@ -1059,7 +1059,7 @@ void Configuration::readBonds() {
} }
// If we don't have enough room in our bond array, we need to expand it. // If we don't have enough room in our bond array, we need to expand it.
if (numBonds >= capacity) { if (numBonds+1 >= capacity) { // "numBonds+1" because we are adding two bonds to array
// Temporary pointer to the old array // Temporary pointer to the old array
Bond* temp = bonds; Bond* temp = bonds;
...@@ -1087,6 +1087,11 @@ void Configuration::readBonds() { ...@@ -1087,6 +1087,11 @@ void Configuration::readBonds() {
continue; continue;
}*/ }*/
if (ind1 < 0 || ind1 >= num || ind2 < 0 || ind2 >=num) {
printf("ERROR: Bond file line '%s' includes invalid index\n", line);
exit(1);
}
Bond* b = new Bond(op, ind1, ind2, file_name); Bond* b = new Bond(op, ind1, ind2, file_name);
bonds[numBonds++] = *b; bonds[numBonds++] = *b;
b = new Bond(op, ind2, ind1, file_name); b = new Bond(op, ind2, ind1, file_name);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* TODO eventually * TODO eventually
** enable flag to disable physics-checking assertions in kernels (also write these assertions)
** split computation into multiple regions ** split computation into multiple regions
*** simulate regions, also in overlap *** simulate regions, also in overlap
**** atoms at edge of overlap can have DoF frozen **** atoms at edge of overlap can have DoF frozen
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment