From b9fa4e1db2523d56449c85d18bf7a3ed413716ad Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 6 Aug 2021 08:13:03 -0400 Subject: [PATCH] avoid memory leaks on specifying keywords multiple times --- src/PYTHON/python_impl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 61092e90ed..2da5f68895 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -179,6 +179,7 @@ void PythonImpl::command(int narg, char **arg) ninput = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ninput < 0) error->all(FLERR,"Invalid python command"); iarg += 2; + delete[] istr; istr = new char*[ninput]; if (iarg+ninput > narg) error->all(FLERR,"Invalid python command"); for (int i = 0; i < ninput; i++) istr[i] = arg[iarg+i]; @@ -186,6 +187,7 @@ void PythonImpl::command(int narg, char **arg) } else if (strcmp(arg[iarg],"return") == 0) { if (iarg+2 > narg) error->all(FLERR,"Invalid python command"); noutput = 1; + delete[] ostr; ostr = arg[iarg+1]; iarg += 2; } else if (strcmp(arg[iarg],"format") == 0) {