Fix memory allocation error when memory size is larger than 2G. Fixes #1606

PiperOrigin-RevId: 627058355
Change-Id: Iebef647a0107d1f112a876d705f5b3ea888b4a41
This commit is contained in:
Yuval Tassa
2024-04-22 09:14:43 -07:00
committed by Copybara-Service
parent 6540289eb1
commit 546a27ca72
9 changed files with 102 additions and 26 deletions
+1 -1
View File
@@ -1186,7 +1186,7 @@ void mjXReader::Size(XMLElement* section, mjSpec* mod) {
}();
if (memory.has_value()) {
if (*memory / sizeof(mjtNum) > std::numeric_limits<int>::max()) {
if (*memory / sizeof(mjtNum) > std::numeric_limits<std::size_t>::max()) {
throw mjXError(section, "%s", err_msg);
}
mod->memory = *memory;