PVS: V522 There might be dereferencing of a potential null pointer

This commit is contained in:
wmayer
2020-07-17 11:01:14 +02:00
parent 39fe47b9de
commit e9bc970c28
15 changed files with 78 additions and 87 deletions

View File

@@ -2087,14 +2087,16 @@ int FemMesh::addGroup(const std::string TypeString, const std::string Name, cons
return aId;
}
void FemMesh::addGroupElements(const int GroupId, const std::set<int> ElementIds)
void FemMesh::addGroupElements(int GroupId, const std::set<int>& ElementIds)
{
SMESH_Group* group = this->getSMesh()->GetGroup(GroupId);
if (!group) {
throw std::runtime_error("AddGroupElements: No group for given id.");
}
SMESHDS_Group* groupDS = dynamic_cast<SMESHDS_Group*>(group->GetGroupDS());
// TODO: is this dynamic_cast OK?
if (!groupDS) {
throw std::runtime_error("addGroupElements: Failed to add group elements.");
}
// Traverse the full mesh and add elements to group if id is in set 'ids'
// and if group type is compatible with element