Replace mjtSize with size_t for size calculations in engine.
Use unsigned size_t instead of signed mjtSize for size multiplications to avoid Clang's overflow-checking intrinsic. This is semantically correct as size calculations are inherently unsigned. PiperOrigin-RevId: 860213177 Change-Id: I837aa6556335478969d4977492d0f231419f020a
This commit is contained in:
committed by
Copybara-Service
parent
68537e1e32
commit
a5de40b400
@@ -1830,13 +1830,13 @@ const char* mj_validateReferences(const mjModel* m) {
|
||||
}
|
||||
}
|
||||
for (int i=0; i < m->nhfield; i++) {
|
||||
mjtSize hfield_adr = m->hfield_adr[i] + ((mjtSize) m->hfield_nrow[i]) * m->hfield_ncol[i];
|
||||
mjtSize hfield_adr = m->hfield_adr[i] + ((size_t) m->hfield_nrow[i]) * m->hfield_ncol[i];
|
||||
if (hfield_adr > m->nhfielddata || m->hfield_adr[i] < 0) {
|
||||
return "Invalid model: hfield_adr out of bounds.";
|
||||
}
|
||||
}
|
||||
for (int i=0; i < m->ntex; i++) {
|
||||
mjtSize nbytes = ((mjtSize) m->tex_nchannel[i]) * m->tex_height[i] * m->tex_width[i];
|
||||
mjtSize nbytes = ((size_t) m->tex_nchannel[i]) * m->tex_height[i] * m->tex_width[i];
|
||||
if (m->tex_adr[i] + nbytes > m->ntexdata || m->tex_adr[i] < 0) {
|
||||
return "Invalid model: tex_adr out of bounds.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user