summaryrefslogtreecommitdiff
path: root/src/mem.c
diff options
context:
space:
mode:
authorarmink <[email protected]>2017-08-14 15:57:42 +0800
committerarmink <[email protected]>2017-08-14 16:09:54 +0800
commita7e7b3dc0274975a6faec637ad2561412c0f0884 (patch)
tree2468553dc8fdf6975b5f10833b3c4c009077250b /src/mem.c
parent07514c0d0a7a15ab7d195ed46e1bbe099e394640 (diff)
[Kernel] Fix rt_realloc issue when new size is 0.
Diffstat (limited to 'src/mem.c')
-rw-r--r--src/mem.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mem.c b/src/mem.c
index b19e46d524..94e9474f7c 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -24,6 +24,7 @@
* fix memory check in rt_realloc function
* 2010-07-13 Bernard fix RT_ALIGN issue found by kuronca
* 2010-10-14 Bernard fix rt_realloc issue when realloc a NULL pointer.
+ * 2017-07-14 armink fix rt_realloc issue when new size is 0
*/
/*
@@ -400,6 +401,11 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
return RT_NULL;
}
+ else if (newsize == 0)
+ {
+ rt_free(rmem);
+ return RT_NULL;
+ }
/* allocate a new memory block */
if (rmem == RT_NULL)
@@ -589,4 +595,3 @@ FINSH_FUNCTION_EXPORT(list_mem, list memory usage information)
#endif /* end of RT_USING_HEAP */
#endif /* end of RT_USING_MEMHEAP_AS_HEAP */
-