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))