Skip to content

Commit 589eb29

Browse files
earlephilhowerigrr
authored andcommitted
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
1 parent 0fe7259 commit 589eb29

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cores/esp8266/umm_malloc/umm_malloc.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,9 @@ void *umm_calloc( size_t num, size_t item_size ) {
16851685

16861686
size += POISON_SIZE(size);
16871687
ret = _umm_malloc(size);
1688-
memset(ret, 0x00, size);
1688+
if (ret) {
1689+
memset(ret, 0x00, size);
1690+
}
16891691

16901692
ret = GET_POISONED(ret, size);
16911693

0 commit comments

Comments
 (0)