From 589eb29eb322b12976b6bc64761372123838d60c Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 20 Jan 2018 20:14:37 -0800 Subject: [PATCH] Clear calloc block only if malloc succeeds Calloc was calling memset(0) on NULL when its implicit malloc failed, causing a crash in UMM. Instead, only do the memset if the memory allocation succeeds. Fixes issue #4207 --- cores/esp8266/umm_malloc/umm_malloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/umm_malloc/umm_malloc.c b/cores/esp8266/umm_malloc/umm_malloc.c index 030042a1f..ac249b643 100644 --- a/cores/esp8266/umm_malloc/umm_malloc.c +++ b/cores/esp8266/umm_malloc/umm_malloc.c @@ -1685,7 +1685,9 @@ void *umm_calloc( size_t num, size_t item_size ) { size += POISON_SIZE(size); ret = _umm_malloc(size); - memset(ret, 0x00, size); + if (ret) { + memset(ret, 0x00, size); + } ret = GET_POISONED(ret, size);