Skip to content

Commit 875f2fc

Browse files
crafcat7xiaoxiang781216
authored andcommitted
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 <chenrun1@xiaomi.com>
1 parent e047828 commit 875f2fc

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

benchmarks/ramspeed/ramspeed_main.c

-16
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,6 @@ static void parse_commandline(int argc, FAR char **argv,
187187
}
188188
}
189189

190-
if (info->allocate_rw_address)
191-
{
192-
info->dest = malloc(info->size);
193-
if (info->dest == NULL)
194-
{
195-
printf(RAMSPEED_PREFIX "Dest Alloc Memory Failed!\n");
196-
}
197-
198-
info->src = malloc(info->size);
199-
if (info->src == NULL)
200-
{
201-
free(info->dest);
202-
printf(RAMSPEED_PREFIX "Src Alloc Memory Failed!\n");
203-
}
204-
}
205-
206190
if ((info->dest == NULL && !info->allocate_rw_address) || info->size == 0)
207191
{
208192
printf(RAMSPEED_PREFIX "Missing required arguments\n");

0 commit comments

Comments
 (0)