don't run atof() on a NULL pointer in case a potential file has an empty line

This commit is contained in:
Axel Kohlmeyer 2020-03-04 13:57:38 -05:00
parent 6354777d09
commit 3ca93f10b3
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
2 changed files with 2 additions and 2 deletions

View File

@ -927,7 +927,7 @@ void PairADP::grab(FILE *fp, char *filename, int n, double *list)
while (i < n) {
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
ptr = strtok(line," \t\n\r\f");
list[i++] = atof(ptr);
if (ptr) list[i++] = atof(ptr);
while ((ptr = strtok(NULL," \t\n\r\f"))) list[i++] = atof(ptr);
}
}

View File

@ -797,7 +797,7 @@ void PairEAM::grab(FILE *fptr, int n, double *list)
while (i < n) {
utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error);
ptr = strtok(line," \t\n\r\f");
list[i++] = atof(ptr);
if (ptr) list[i++] = atof(ptr);
while ((ptr = strtok(NULL," \t\n\r\f"))) list[i++] = atof(ptr);
}
}