diff --git a/libraries/AP_HAL_ChibiOS/Util.cpp b/libraries/AP_HAL_ChibiOS/Util.cpp index ec3e43fa5a..2d0015cd76 100644 --- a/libraries/AP_HAL_ChibiOS/Util.cpp +++ b/libraries/AP_HAL_ChibiOS/Util.cpp @@ -52,7 +52,7 @@ void* Util::malloc_type(size_t size, AP_HAL::Util::Memory_Type mem_type) if (mem_type == AP_HAL::Util::MEM_FAST) { return try_alloc_from_ccm_ram(size); } else { - return malloc(size); + return calloc(1, size); } } @@ -69,7 +69,7 @@ void* Util::try_alloc_from_ccm_ram(size_t size) void *ret = malloc_ccm(size); if (ret == nullptr) { //we failed to allocate from CCM so we are going to try common SRAM - ret = malloc(size); + ret = calloc(1, size); } return ret; }