diff --git a/src/memheap.c b/src/memheap.c index 68a15d1a8e446d517e7e4263187777f338ad990f..9c3f570f2949eb251ae821dc01ce546479c1564c 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