From 27a273293618e6dbc2de5b299247b1d9f05864c6 Mon Sep 17 00:00:00 2001 From: dante Date: Wed, 11 May 2022 13:19:43 +0200 Subject: Use calloc instead of malloc and memset Change-Id: I591ee7f5360a30779f831f6492cdbe71ab94099e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134165 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sal/rtl/alloc_global.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sal') diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx index 9ceba4f4120f..4b7ec6037dc1 100644 --- a/sal/rtl/alloc_global.cxx +++ b/sal/rtl/alloc_global.cxx @@ -53,10 +53,8 @@ void SAL_CALL rtl_freeMemory(void * p) SAL_THROW_EXTERN_C() void * SAL_CALL rtl_allocateZeroMemory(sal_Size n) SAL_THROW_EXTERN_C() { - void * p = rtl_allocateMemory (n); - if (p) - memset (p, 0, n); - return p; + SAL_WARN_IF( n >= SAL_MAX_INT32, "sal.rtl", "suspicious massive alloc " << n); + return calloc(n, 1); } void SAL_CALL rtl_freeZeroMemory(void * p, sal_Size n) SAL_THROW_EXTERN_C() -- cgit v1.2.3