Skip to content

Commit 74791e1

Browse files
committed
Node numbers are now validated when building edges from the input file.
1 parent 547b4fc commit 74791e1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

FEBioXML/FEBModel.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,16 @@ bool FEBModel::BuildPart(FEModel& fem, Part& part, bool buildDomains, const Tran
543543

544544
seg.ntype = edge.ntype;
545545
int nn = edge.ntype; // we assume that the type also identifies the number of nodes
546-
for (int n = 0; n < nn; ++n) seg.node[n] = NLT[edge.node[n] - noff];
546+
for (int n = 0; n < nn; ++n)
547+
{
548+
int nid = edge.node[n] - noff;
549+
if (nid < 0 || nid >= NLT.size() || NLT[nid] < 0)
550+
{
551+
feLogErrorEx(&fem, "Invalid node index %d in edge set %s", edge.node[n], edgeSet->Name().c_str());
552+
return false;
553+
}
554+
seg.node[n] = NLT[nid];
555+
}
547556
}
548557

549558
// add it to the mesh

0 commit comments

Comments
 (0)