From 4246e6c768543197f723a608f36577d945e2ccda Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 21 Jun 2022 12:07:00 +0100 Subject: [PATCH] Fix #1599 --- mongoose.h | 4 ++-- src/arch_freertos_lwip.h | 2 +- src/arch_freertos_tcp.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mongoose.h b/mongoose.h index cddeb2c4..5cea0b62 100644 --- a/mongoose.h +++ b/mongoose.h @@ -192,7 +192,7 @@ struct timeval { // Re-route calloc/free to the FreeRTOS's functions, don't use stdlib static inline void *mg_calloc(int cnt, size_t size) { void *p = pvPortMalloc(cnt * size); - if (p != NULL) memset(p, 0, size); + if (p != NULL) memset(p, 0, size * cnt); return p; } #define calloc(a, b) mg_calloc((a), (b)) @@ -262,7 +262,7 @@ static inline void *mg_calloc(int cnt, size_t size) { // Re-route calloc/free to the FreeRTOS's functions, don't use stdlib static inline void *mg_calloc(int cnt, size_t size) { void *p = pvPortMalloc(cnt * size); - if (p != NULL) memset(p, 0, size); + if (p != NULL) memset(p, 0, size * cnt); return p; } #define calloc(a, b) mg_calloc((a), (b)) diff --git a/src/arch_freertos_lwip.h b/src/arch_freertos_lwip.h index 8abf453d..623f0e55 100644 --- a/src/arch_freertos_lwip.h +++ b/src/arch_freertos_lwip.h @@ -32,7 +32,7 @@ struct timeval { // Re-route calloc/free to the FreeRTOS's functions, don't use stdlib static inline void *mg_calloc(int cnt, size_t size) { void *p = pvPortMalloc(cnt * size); - if (p != NULL) memset(p, 0, size); + if (p != NULL) memset(p, 0, size * cnt); return p; } #define calloc(a, b) mg_calloc((a), (b)) diff --git a/src/arch_freertos_tcp.h b/src/arch_freertos_tcp.h index 35ecfe3e..797f66c7 100644 --- a/src/arch_freertos_tcp.h +++ b/src/arch_freertos_tcp.h @@ -50,7 +50,7 @@ // Re-route calloc/free to the FreeRTOS's functions, don't use stdlib static inline void *mg_calloc(int cnt, size_t size) { void *p = pvPortMalloc(cnt * size); - if (p != NULL) memset(p, 0, size); + if (p != NULL) memset(p, 0, size * cnt); return p; } #define calloc(a, b) mg_calloc((a), (b))