Unverified Commit e62746ef authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

protect group command against options that require unavailble properties resulting in segfaults

parent a5c93e75
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -207,6 +207,12 @@ void Group::assign(int narg, char **arg)
    else if (strcmp(arg[1],"molecule") == 0) category = MOLECULE;
    else if (strcmp(arg[1],"id") == 0) category = ID;

    if ((category == MOLECULE) && (!atom->molecular))
      error->all(FLERR,"Group command requires atom attribute molecule");

    if ((category == ID) && (!atom->tag_enable))
      error->all(FLERR,"Group command requires atom IDs");

    // args = logical condition

    if (narg > 3 &&
@@ -362,11 +368,14 @@ void Group::assign(int narg, char **arg)
  } else if (strcmp(arg[1],"include") == 0) {

    if (narg != 3) error->all(FLERR,"Illegal group command");
    if (strcmp(arg[2],"molecule") != 0)
      error->all(FLERR,"Illegal group command");
    if (strcmp(arg[2],"molecule") == 0) {
      if (!atom->molecular)
        error->all(FLERR,"Group command requires atom attribute molecule");

      add_molecules(igroup,bit);

    } else error->all(FLERR,"Illegal group command");

  // style = subtract

  } else if (strcmp(arg[1],"subtract") == 0) {