Fix null-pointer dereference in nano-malloc
If p is NULL, then the free_list is empty and we should return the correct failure values.
This commit is contained in:
parent
43ab30fbd5
commit
73d515fcfe
|
@ -322,7 +322,7 @@ void * nano_malloc(RARG malloc_size_t s)
|
||||||
r=r->next;
|
r=r->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((char *)p + p->size == (char *)_SBRK_R(RCALL 0))
|
if (p != NULL && (char *)p + p->size == (char *)_SBRK_R(RCALL 0))
|
||||||
{
|
{
|
||||||
/* The last free item has the heap end as neighbour.
|
/* The last free item has the heap end as neighbour.
|
||||||
* Let's ask for a smaller amount and merge */
|
* Let's ask for a smaller amount and merge */
|
||||||
|
|
Loading…
Reference in New Issue