You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/08/08 01:52:03 UTC
(nuttx-apps) 03/03: ramspeed:Fix memleak due to double malloc.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 875f2fcc1e4aed074d75172ad3d4aaef39edf937
Author: chenrun1 <ch...@xiaomi.com>
AuthorDate: Thu Apr 11 20:40:49 2024 +0800
ramspeed:Fix memleak due to double malloc.
if (allocate_rw_address)
{
info->dest = malloc(info->size);
info->src = malloc(info->size);
}
if ((info->dest == NULL && !info->allocate_rw_address) || info->size == 0)
{
printf(RAMSPEED_PREFIX "Missing required arguments\n");
goto out;
}
else
{
/* We need to automatically apply for memory */
printf(RAMSPEED_PREFIX "Allocate RW buffers on heap\n");
info->dest = malloc(info->size);
if (info->dest == NULL)
{
printf(RAMSPEED_PREFIX "Dest Alloc Memory Failed!\n");
goto out;
}
info->src = malloc(info->size);
if (info->src == NULL)
{
printf(RAMSPEED_PREFIX "Src Alloc Memory Failed!\n");
goto out;
}
}
Signed-off-by: chenrun1 <ch...@xiaomi.com>
---
benchmarks/ramspeed/ramspeed_main.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/benchmarks/ramspeed/ramspeed_main.c b/benchmarks/ramspeed/ramspeed_main.c
index 7c1b1c3d3..2432f67d8 100644
--- a/benchmarks/ramspeed/ramspeed_main.c
+++ b/benchmarks/ramspeed/ramspeed_main.c
@@ -187,22 +187,6 @@ static void parse_commandline(int argc, FAR char **argv,
}
}
- if (info->allocate_rw_address)
- {
- info->dest = malloc(info->size);
- if (info->dest == NULL)
- {
- printf(RAMSPEED_PREFIX "Dest Alloc Memory Failed!\n");
- }
-
- info->src = malloc(info->size);
- if (info->src == NULL)
- {
- free(info->dest);
- printf(RAMSPEED_PREFIX "Src Alloc Memory Failed!\n");
- }
- }
-
if ((info->dest == NULL && !info->allocate_rw_address) || info->size == 0)
{
printf(RAMSPEED_PREFIX "Missing required arguments\n");