From 120c080fc2fa60aaeb37bc14c252662f6865549c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 28 Mar 2022 15:07:23 -0400 Subject: [PATCH] avoid converting a null pointer to a std::string and correct error check --- src/KIM/pair_kim.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 9f5ce8a99f..d3e1c2ee9a 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -307,15 +307,14 @@ void PairKIM::settings(int narg, char **arg) ++settings_call_count; init_style_call_count = 0; - if (narg != 1) { - const std::string arg_str(arg[0]); - if ((narg > 0) && - ((arg_str == "KIMvirial") || (arg_str == "LAMMPSvirial"))) { - error->all(FLERR,"'KIMvirial' or 'LAMMPSvirial' not supported " - "with kim-api"); + // arg[0] is the KIM Model name + if (narg == 0) error->all(FLERR,"Illegal pair_style command"); + if (narg > 1) { + const std::string arg_str(arg[1]); + if ((arg_str == "KIMvirial") || (arg_str == "LAMMPSvirial")) { + error->all(FLERR,"'KIMvirial' or 'LAMMPSvirial' not supported with kim-api"); } else error->all(FLERR,"Illegal pair_style command"); } - // arg[0] is the KIM Model name lmps_using_molecular = (atom->molecular > 0);