mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
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
This commit is contained in:
parent
0fe725909e
commit
589eb29eb3
@ -1685,7 +1685,9 @@ void *umm_calloc( size_t num, size_t item_size ) {
|
|||||||
|
|
||||||
size += POISON_SIZE(size);
|
size += POISON_SIZE(size);
|
||||||
ret = _umm_malloc(size);
|
ret = _umm_malloc(size);
|
||||||
memset(ret, 0x00, size);
|
if (ret) {
|
||||||
|
memset(ret, 0x00, size);
|
||||||
|
}
|
||||||
|
|
||||||
ret = GET_POISONED(ret, size);
|
ret = GET_POISONED(ret, size);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user