avoid segfaults when accessing lammps_last_thermo()
This commit is contained in:
@ -858,14 +858,17 @@ void *lammps_last_thermo(void *handle, const char *what, int index)
|
||||
{
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
void *val = nullptr;
|
||||
|
||||
if (!lmp->output) return val;
|
||||
Thermo *th = lmp->output->thermo;
|
||||
if (!th) return nullptr;
|
||||
if (!th) return val;
|
||||
const int nfield = *th->get_nfield();
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
if (strcmp(what, "setup") == 0) {
|
||||
val = (void *) &lmp->update->setupflag;
|
||||
if (lmp->update)
|
||||
val = (void *) &lmp->update->setupflag;
|
||||
|
||||
} else if (strcmp(what, "line") == 0) {
|
||||
val = (void *) th->get_line();
|
||||
|
||||
Reference in New Issue
Block a user