do not call memset on a null pointer

This commit is contained in:
Axel Kohlmeyer
2021-09-24 15:32:59 -04:00
parent 42dca75225
commit 973cf017a9

View File

@ -1321,7 +1321,7 @@ void ReadData::bonds(int firstpass)
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
if (count) memset(count,0,nlocal*sizeof(int));
}
// read and process bonds
@ -1395,7 +1395,7 @@ void ReadData::angles(int firstpass)
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
if (count) memset(count,0,nlocal*sizeof(int));
}
// read and process angles
@ -1469,7 +1469,7 @@ void ReadData::dihedrals(int firstpass)
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
if (count) memset(count,0,nlocal*sizeof(int));
}
// read and process dihedrals
@ -1543,7 +1543,7 @@ void ReadData::impropers(int firstpass)
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
if (count) memset(count,0,nlocal*sizeof(int));
}
// read and process impropers