diff --git a/src/atom.cpp b/src/atom.cpp index 4135298673..111ce7c93c 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -2471,7 +2471,7 @@ This function is called, e.g. from :doc:`fix property/atom `. */ int Atom::add_custom(const char *name, int flag, int cols) { - int index; + int index = -1; if ((flag == 0) && (cols == 0)) { index = nivector; @@ -2511,7 +2511,8 @@ int Atom::add_custom(const char *name, int flag, int cols) dcols = (int *) memory->srealloc(dcols,ndarray*sizeof(int),"atom:dcols"); dcols[index] = cols; } - + if (index < 0) + error->all(FLERR,"Invalid call to Atom::add_custom()"); return index; }