From a5de40b400afdf075837da37dfe739f8965b9584 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Fri, 23 Jan 2026 12:34:13 -0800 Subject: [PATCH] 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 --- src/engine/engine_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/engine_io.c b/src/engine/engine_io.c index 504011bf..749b7593 100644 --- a/src/engine/engine_io.c +++ b/src/engine/engine_io.c @@ -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."; }