summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/memheap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/memheap.c b/src/memheap.c
index 68a15d1a8e..9c3f570f29 100644
--- a/src/memheap.c
+++ b/src/memheap.c
@@ -850,6 +850,10 @@ void *rt_malloc(rt_size_t size)
{
void *ptr;
+ /* zero size, return RT_NULL */
+ if (size == 0)
+ return RT_NULL;
+
/* try to allocate in system heap */
ptr = rt_memheap_alloc(&_heap, size);
#ifdef RT_USING_MEMHEAP_AUTO_BINDING