Merge pull request #3085 from Ashutosh0x:fix/windows-zero-alloc

PiperOrigin-RevId: 870765044
Change-Id: I91b6a6096fe58200f8b36fda62838046a9ee08fe
This commit is contained in:
Copybara-Service
2026-02-16 01:47:04 -08:00
+6 -4
View File
@@ -207,16 +207,18 @@ void* mju_malloc(size_t size) {
// default allocator // default allocator
else { else {
// pad size to multiple of 64 // pad size to multiple of 64
if ((size%64)) { if (size > 0 && (size % 64)) {
size += 64 - (size%64); size += 64 - (size % 64);
} }
// allocate // allocate
ptr = mju_alignedMalloc(size, 64); if (size > 0) {
ptr = mju_alignedMalloc(size, 64);
}
} }
// error if null pointer // error if null pointer
if (!ptr) { if (!ptr && size > 0) {
mju_error("Could not allocate memory"); mju_error("Could not allocate memory");
} }