Add check for height fields size during compilation.

Fixes #2427.

PiperOrigin-RevId: 727805729
Change-Id: Idf3192e5fb238249faaeae6b4fb9de4c55755d96
This commit is contained in:
Alessio Quaglino
2025-02-17 04:00:35 -08:00
committed by Copybara-Service
parent 78a4d2f389
commit 7f11a0df12
2 changed files with 27 additions and 0 deletions
+3
View File
@@ -3696,6 +3696,9 @@ void mjCHField::Compile(const mjVFS* vfs) {
// copy userdata into data
if (!userdata_.empty()) {
if (nrow*ncol != userdata_.size()) {
throw mjCError(this, "elevation data length must match nrow*ncol");
}
data.assign(nrow*ncol, 0);
if (data.empty()) {
throw mjCError(this, "could not allocate buffers in hfield");