Add bounds check for cached node indices in passive mesh.
The global node indices stored in face_gidx are now checked to ensure they are within the valid range of node numbers, raising an error if any index is out of bounds. PiperOrigin-RevId: 916025763 Change-Id: I1d2dcb11603137c337493541066b62b2ed2854c0
This commit is contained in:
committed by
Copybara-Service
parent
a0c4c62654
commit
093b92acc1
@@ -280,6 +280,14 @@ static void mj_flexPassiveBendInterp(const mjModel* m, mjData* d, int f,
|
||||
face_gidx + fi * npe, face_quat + fi * 4);
|
||||
}
|
||||
|
||||
// check cached node indices are in bounds
|
||||
for (int i = 0; i < nfaces * npe; i++) {
|
||||
if (face_gidx[i] < 0 || face_gidx[i] >= nodenum) {
|
||||
mjERROR("cached node index out of range: face_gidx[%d]=%d, nodenum=%d",
|
||||
i, face_gidx[i], nodenum);
|
||||
}
|
||||
}
|
||||
|
||||
// per-edge temporaries
|
||||
mjtNum* xpos_A = mjSTACKALLOC(d, 3*npe, mjtNum);
|
||||
mjtNum* xpos_B = mjSTACKALLOC(d, 3*npe, mjtNum);
|
||||
|
||||
Reference in New Issue
Block a user