diff --git a/ulib/dlmalloc/dlmalloc_port.inc b/ulib/dlmalloc/dlmalloc_port.inc index b5c7fa2..8ead8fb 100644 --- a/ulib/dlmalloc/dlmalloc_port.inc +++ b/ulib/dlmalloc/dlmalloc_port.inc @@ -72,11 +72,11 @@ void *sbrk(ptrdiff_t inc) { uint64_t pages = _roundpage(inc); uint8_t *maddr = NULL; int32_t ret = mman_map(NULL, pages, MMAN_MAP_PF_RW, 0, &maddr); - if (ret != E_OK) { + if (ret != E_OK || maddr == NULL) { return 0; } string_memset(maddr, 0, pages); - _last = (void *)(maddr + inc); + _last = (void *)(maddr + pages); return maddr; }