diff --git a/src/angle_write.cpp b/src/angle_write.cpp index e7c95be3cf..e64c2f23c8 100644 --- a/src/angle_write.cpp +++ b/src/angle_write.cpp @@ -66,6 +66,7 @@ void AngleWrite::command(int narg, char **arg) int n = utils::inumeric(FLERR, arg[1], false, lmp); std::string table_file = arg[2]; std::string keyword = arg[3]; + if (n < 2) error->all(FLERR, "Must have at least 2 table values"); // make sure system is initialized before calling any functions diff --git a/src/bond.cpp b/src/bond.cpp index f14cae1090..08fb36a75f 100644 --- a/src/bond.cpp +++ b/src/bond.cpp @@ -362,6 +362,7 @@ void Bond::write_file(int narg, char **arg) if ((inner <= 0.0) || (inner >= outer)) error->all(FLERR, "Invalid rlo={} / rhi={} values in bond_write command.", inner, outer); + if (n < 2) error->all(FLERR, "Must have at least 2 table values"); double r0 = equilibrium_distance(btype); // open file in append mode if exists diff --git a/src/dihedral_write.cpp b/src/dihedral_write.cpp index eedcde0eb8..285d9cf931 100644 --- a/src/dihedral_write.cpp +++ b/src/dihedral_write.cpp @@ -69,6 +69,7 @@ void DihedralWrite::command(int narg, char **arg) int n = utils::inumeric(FLERR, arg[1], false, lmp); std::string table_file = arg[2]; std::string keyword = arg[3]; + if (n < 2) error->all(FLERR, "Must have at least 2 table values"); // make sure system is initialized before calling any functions diff --git a/src/pair.cpp b/src/pair.cpp index 44a63f211b..6c0de4bab7 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -1806,6 +1806,8 @@ void Pair::write_file(int narg, char **arg) else if (strcmp(arg[3],"bitmap") == 0) style = BMP; else error->all(FLERR,"Invalid style in pair_write command"); + if (n < 2) error->all(FLERR, "Must have at least 2 table values"); + double inner = utils::numeric(FLERR,arg[4],false,lmp); double outer = utils::numeric(FLERR,arg[5],false,lmp); if (inner <= 0.0 || inner >= outer)