fix segfault when processing empty lines

This commit is contained in:
Axel Kohlmeyer
2021-03-16 23:41:18 -04:00
parent 42895ac6df
commit a76a8eae59

View File

@ -444,12 +444,11 @@ is passed to :cpp:func:`lammps_commands_string` for processing.
void lammps_commands_list(void *handle, int ncmd, const char **cmds)
{
LAMMPS *lmp = (LAMMPS *) handle;
std::string allcmds;
for (int i = 0; i < ncmd; i++) {
allcmds.append(cmds[i]);
if (allcmds.back() != '\n') allcmds.append(1,'\n');
if (allcmds.empty() || (allcmds.back() != '\n')) allcmds.append(1,'\n');
}
lammps_commands_string(handle,allcmds.c_str());