Browse Source

Fixed a memory corruption issue in rt_realloc().

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@495 bbd45198-f89e-11dd-88c7-29a3b14d5316
kyle.hu.gz 15 years ago
parent
commit
9ac8c55353
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/mem.c

+ 1 - 1
src/mem.c

@@ -396,7 +396,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
 
 	/* expand memory */
 	nmem = rt_malloc(newsize);
-	rt_memcpy(nmem, rmem, size);
+	rt_memcpy(nmem, rmem, size < newsize ? size : newsize);
 
 	rt_free(rmem);