fix out-of-range memory access in sort function

This commit is contained in:
Axel Kohlmeyer
2022-08-30 14:27:28 -04:00
parent 3c52be6a44
commit 4c64a2f2a1

View File

@ -1424,10 +1424,11 @@ void PairMesoCNT::sort(int *list, int size)
j = i;
temp1 = list[j - 1];
temp2 = list[j];
while (j > 0 && tag[temp1] > tag[temp2]) {
while (tag[temp1] > tag[temp2]) {
list[j] = temp1;
list[j - 1] = temp2;
j--;
if (j == 0) break;
temp1 = list[j - 1];
temp2 = list[j];
}