From eaf5e085422f27acec1014d56ed94c0eaed215b2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 24 Aug 2021 14:27:20 -0400 Subject: [PATCH] detect invalid use and silence compiler warnings --- src/atom.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; }